World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
RobertS 13-Sep-2007 [871x2] | let me fire up Rebo/View again |
but how will this help me where I have a WORD that is holding that initial, partial, path ? | |
Chris 13-Sep-2007 [873x2] | join to-path do path 'a |
path: 't2/f do join to-path do path 'a | |
RobertS 13-Sep-2007 [875x2] | ;same error >> t1: [a "one"] == [a "one"] >> t2: [f t1] == [f t1] >> pp: join 't2/f 'a == t2/f/a >> do pp ** Script Error: Cannot use path on word! value ** Where: halt-view ** Near: t2/f/a >> |
2.6.3 just ditched me again with that one ... | |
Chris 13-Sep-2007 [877] | This is the limitation of evaluating paths. 'do does not evalute 't1 when it is returned from 't2/f |
RobertS 13-Sep-2007 [878x2] | I think 2.6.3 does not want 'path used as a word ;-) |
so do you think that to-path reduce [ my-path 'my-next-refinement] the best that I can do? | |
Chris 13-Sep-2007 [880] | If your interpreter chokes on 'join, then I guess so... |
RobertS 13-Sep-2007 [881x4] | I could try just Rebol/Core and see if that make a difference It is not very often that Rebol blows out on me ... I can't remember when last before I started looking at my functor issues |
That's 3 times tonight with only 2 teeny blocks and 2 paths and no do against any file and nothing added to user.r | |
ah-ha ! Works fine in Rebol/Core ! path: 't2/f do join to-path do path 'a | |
Nope. Back to View and this time Rebol did not blow out of the water .... Is there a dump.log that I can look at see what these fatal errors have been ? | |
Chris 13-Sep-2007 [885] | Not sure. Try working with -- trace on |
RobertS 13-Sep-2007 [886] | >> t1: [a "one"] == [a "one"] >> t2: [f t1] == [f t1] >> path: 't2/f == t2/f >> do join to-path do path 'a == "one" ; thanks CHRIS |
Chris 13-Sep-2007 [887] | Hey, if it works : ) |
RobertS 13-Sep-2007 [888] | I would not have stumbled on the do path any too soon, I fear ... ;-) |
Chris 13-Sep-2007 [889] | It's not the most intuitive move, for sure. |
RobertS 13-Sep-2007 [890x7] | I am adding augpath: func [{augment path with a word} to my armory |
Now to find out what typo of mine is able to blow 2.6.3 outa the wadder | |
augpath: func [{ augment a PATH with a WORD }path 'word] [ return join to-path reduce[path] :word] ; augpath t2/f a | |
oops! IGnoring the needless return, that is one word longer than >> pword: func [path 'word /local blk] [ to-path reduce[path :word]] ; ;-) | |
; I mean augpath: func [path 'word ] [ to-path reduce[path :word]] | |
; but IN the interpreter, to use join >> do join to-path do my-path 'a-further-refinement ; is terrific and has led me to my-path: to-path join reduce[ my-path ] 'a-deeper-tag | |
Nope another typo my-path: t2/f That is trivial It has to be my-path: 't2/f or my-path: to-path [t2 f] | |
Gabriele 13-Sep-2007 [897x3] | JOIN does a reduce, so that's probably your problem. to-path reduce is not doing what you expect there, it's creating a path inside a path (no wonder it may crash :). |
use append copy path word | |
also, you need to reduce your blocks above, because you have words in them, not subblocks. | |
RobertS 13-Sep-2007 [900x6] | Thanks. I should also have used a type block in my func augpath: func [ {augment a path with a word} path [path!] functor [ word! ] /local p ] [ |
Once there are only subblocks it becomes trivial; I have been trying to augment a path! series which starts with a block in which a tagged-word is bound to a block . By augment the path I mean to return a path, not the result of evaluating the path t1: [ a-word-with-no-value-functor "one" ] t2: [ functor t1 ] ; t1 is a word, not a block, but is bound to a block at the time the path is extended into it ( if possible without t2 being an object! ) t2: context [ functor t1] ; also trivial | |
; this work fine for traversal >> navpath: func [ pth [path!] 'wrd [word!] /local p42 ] [ [ p42: do pth [ to-path reduce [p42 :wrd]] >> pp: navpath path a == t1/a >> do pp == "one" | |
where path was path: to-path [ t2 f ] | |
>> t1 == [a "one"] >> t2: context [f: t1] >> t2/f == [a "one"] >> t2/f/a == "one" >> first t1 == a >> get first t1 ** Script Error: a has no value ** Where: halt-view ** Near: get first t1 >> get first third t2 == [a "one"] | |
>> do append copy 't2/f 'a == "one" | |
Gabriele 13-Sep-2007 [906x3] | if you want to have words instead of the actual blocks in your blocks, then you need to "evaluate" the path yourself, which is not too hard. |
>> b1: [a b2 c b3] == [a b2 c b3] >> b2: [d b3] == [d b3] >> b3: [e 4] == [e 4] >> eval-path: func [path /local val] [ [ val: get first path [ foreach elem next path [ [ val: select val elem [ if word? val [val: get val] [ ] [ val [ ] >> eval-path 'b1/a/d/e == 4 | |
(this assumes all elements of the path are blocks) | |
RobertS 14-Sep-2007 [909] | I realized there was this traversal option using a lit-path! treated as a series! but it did not seem to if what I already had was a path! held by a word and I wanted to 'extend' that value with a word. This arises when the embedded word becomes bound to a different block. In that case an OBJECT! looks to be the only option but then the WORDSs in the PATH come already bound to values and so are not 'functors' as are 'a 'd and 'e in your example. I want to construct a resultant valid path! from a valid path! + a lit-word where that word has no value but serves only as functor. I had hoped that the func to-lit-path would be the answer, but I see now that the default Rebol DO path! evaluation precludes this kind of 'append'. I should be able to use a modified version of your eval-path func to take as args a valid path! and a word! My path idea is more like a 'tilde' than our '/' such that I can have ; blk/key~wrd1~wrd2~wrd3 ... ~wrd-n ; e.g., path~wrd1~wrd-i~wrd-j ~wrd-k ; becomes ; ... path2~wrd-m~wrd-n ; i.e., ; blk/key/putative-confirmed-key~wrd-m~wrd-n PARSE is likely part of the answer if I go that TILDE route. Once I have a lit-path! your eval-path is the traversal. A blk of args to a func such as construct_dpath: func [ dpath [lit-path!] functor-words-blk [block! ] /local v1 v2] [ should model my case OK and that dpath can be constructed by modified versions of your eval-path. Thanks |
Gabriele 14-Sep-2007 [910x4] | hmm, i'm not really sure what your final goal is. |
>> p: 'b1/a/d == b1/a/d >> append p 'e == b1/a/d/e | |
then you can call eval-path on p | |
i still think it would be much simpler if you just had blocks instead of words there :-) | |
RobertS 14-Sep-2007 [914] | I have this harmless fixation on Oz, the language ;-) It was a kinda prologue to my coming to Rebol lol |
Gabriele 14-Sep-2007 [915] | i'll need to look at it someday... ;) |
PaulB 17-Nov-2007 [916] | Hello, I'm trying to write my first program in REBOL, besides "Hello, World!", heh. Anyway, I am trying to take the output of the DOS ipconfig command and only grab the IP address for my local NIC out of it. I would like to display the IP address only in a window in a large font. I have played with the call command in REBOL and have been able to use call/output to write the output of the command to a text file. My question is what would be the best way of grabbing the IP address I need out of this text file? Maybe there is another way I should be approaching this too, I'm not sure? Your thoughts and suggestions are appreciated. :) |
btiffin 17-Nov-2007 [917x2] | Paul; For one you can skip the intermediate file. Try >> res: make string! 80 call/output "ipconfig" res it'll place the stdout results right in the string res. |
Then you have some options. REBOL has (to name but two) find and parse for this kind of work. | |
Ashley 17-Nov-2007 [919] | Also take a look at the following functions: >> system/network/host >> system/network/host-address |
PaulB 17-Nov-2007 [920] | Great, thank you for the quick answers! I'll take a look at this new information. :) |
older newer | first last |