World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
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 [942x2] | also: |
>> probe get-modes tcp:// 'interfaces [make object! [ name: "lo" addr: 127.0.0.1 netmask: 255.0.0.0 broadcast: none dest-addr: none flags: [loopback] ] make object! [ name: "eth0" addr: 192.168.1.4 netmask: 255.255.255.0 broadcast: 192.168.1.255 dest-addr: none flags: [broadcast multicast] ]] | |
PaulB 19-Nov-2007 [944] | Very interesting guys, thanks for all the great comments. You are showing me a lot of options in REBOL for this kind of stuff, I like it. |
Joe 26-Nov-2007 [945] | Gabriele, when you have multiple alias per nic and multiple nics, how do you go about picking a specific interface for a network connection |
Gabriele 28-Nov-2007 [946x3] | afaik, you can't with rebol. the os picks the interface for you. |
(and when listening, rebol alwasy binds to all interfaces) | |
hopefully, we'll find some way to do than in R3 | |
Michael 12-Jan-2008 [949x4] | I have been playing with Cal Dixon's REM editor and Core as a means of learning code and trying to identify differences between the 2.5 Core he wrote it for and the current version. Everything seems to work fine except SEARCH, which produces the following error... |
** Script Error: if expected then-block argument of type: block ** Where: seach ** Near: if x: sfind temp whatis | |
...in reference to his code block: search: func [ from whatis /reverse /case /local list x y p temp sfind start end step ] [ list: buffer/lines sfind: to-path join [find] [ either case ['case]['only] either reverse ['reverse]['only] ] y: from/y set [start end step] reduce any [ all [ reverse [(y - 1) 1 -1] ] [(y + 1) (length? list) 1] ] temp: at pick list y (from/x + either reverse [-1][1]) return if p: catch [ if x: sfind temp whatis [ throw reduce [ index? x y ] ] for y start end step [ temp: either reverse [ tail pick list y ] [ pick list y ] if x: sfind temp whatis [ throw reduce [ index? x y ] ] ] ] [ to-pair p ] ] | |
What changes need to be made for this to work? Thanks. | |
Gabriele 12-Jan-2008 [953] | path!s are no more word-active. x: do sfind .... should work with the latest rebol (2.7). |
SteveT 12-Jan-2008 [954] | Perspectives of a newbie! By Steve Thornton (SteveT) Hi! everyone, as someone brand new to REBOL I've been asked to log a journal describing my experiences using REBOL. I think the first thing to get out of the way is to tell you where I'm coming to REBOL from. I've programmed on and off for over twenty years starting with Clipper 5 (dBaseII), Visual Basic (Access), C# (SQL Server), Java(NetBeans + JavaDB). I've worked in a variety contract/freelance work. I earn approx half my income form 'Thornton Software' and I work for Iris Software Group - as a training consultant (training accountants :-\ someone has to do it!) I can hear some of you saying 'Ahh! he's an IDE wimp - real men/women code from scratch'. It was strange - every language I've used had an IDE and I was a bit put off having to go find myself an editor. Until something better find's me I'm using the freebie 'CREdit' as recommended by Sunanda. The easiest way to edit/test the scripts is to open an explorer window at the side of the CREdit window showing my scripts folder. I can then drag a .r file onto the CEdit screen and it opens it. To run the script I double-click it in the explorer window. The help and documentation available is better than I have previously experienced. Some of the components I've been wow'ed by so far is Henriks List-View and RebDb from Dobeash. I've looked at RebGUI and for the time being I would prefer not to use anything on top of VID, I need to learn pure VID before using anything else. REBOL Cookbook of examples is a useful place to start. Some more form oriented examples would be cool. Example 014 - 'Open two windows' and Example 10 - 'Simple text form window' are both useful The Event Handling guide is a good resource for programmers moving from Visual Studio etc.. That's more than enough to be going on with, next time I'll cover my experiences with VID, FACES and handling Events. Bye for now. Steve Thornton |
Michael 12-Jan-2008 [955] | Thanks, Gabriele! |
older newer | first last |