r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

RobertS
13-Sep-2007
[893x4]
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. :)
btiffin
17-Nov-2007
[921]
Hey!  I was just about to show some parse code and then you come 
along and make it a freebie.  :)  


Paul;  A good lesson right off the bat.  How ever easy REBOL code 
looks.  There is probably something built-in already.  REBOL is definitely 
a blinders off language.  Then again ... I think Ashley has something 
approaching a super power when it comes to quickly seeing alternate 
solutions and big picture implications.  :)
PaulB
17-Nov-2007
[922x3]
Wow, I just tried Ashley's suggestion, bingo the IP I was looking 
for!
I am actually writing this for use in my job. I am a network support/programmer 
and I work for Nuns. I have been connecting to their computers using 
VNC. I always have to try and tell them how to give me the address 
of their machine after I get them to start VNC. They always have 
trouble. So I thought I could write something in REBOL do they could 
just double click and read it clearly on the screen. That is why 
I mentioned the large font.
do=so
btiffin
17-Nov-2007
[925x3]
Just for fun; here is one way of pulling the output from ipconfig.

parse res [to "IPv4 Address" thru  ": " copy ip to newline to end]
And that is just one way of many.
Oh, the variable ip has the ip address as string! after the parse.
Paul;  If you are still reading.  You owe it to yourself to check 
out  http://www.dobeash.comAshley has offered the community some 
real killer development tools; RebGUI and RebDB being but two ... 
seperately both wonderful tookits, together, a very powerful combination.
PaulB
17-Nov-2007
[928]
Cool, I will definitely check that out. I just bookmarked it. Thank 
you!
Graham
17-Nov-2007
[929x3]
http://www.compkarori.com/cgi-local/whatismyip.r
but that's the outside address
which is what I guess you need for logmein, vnc and remote desktop 
etc
PaulB
17-Nov-2007
[932]
ah, good to know. But actually, I don't want the outside IP, because 
the computers I am connecting too are on our LAN on the same campus. 
But I appreciate the information, it may be helpful later.  :)
Graham
17-Nov-2007
[933]
You work in a convent ?  :)
PaulB
17-Nov-2007
[934x2]
Yes.
there is also a college on the same campus that the nuns started 
a long time ago.
Graham
17-Nov-2007
[936]
why not just assign a static ip address?
PaulB
17-Nov-2007
[937]
Well, there are about 200 computers I would have to do that too.
Graham
17-Nov-2007
[938]
oh :(
PaulB
17-Nov-2007
[939x2]
Hehe, thats okay, this was more about me learning REBOL, I just figured 
if I could use it for work, that would be a bonus!
I just wanted simple to start with.
Luis
18-Nov-2007
[941]
Other way: 
read dns://
read join dns:// read dns://
Gabriele
19-Nov-2007
[942]
also: