[REBOL] pleh! pleh! basic reborientation needed! Re:
Hi Pete, Sometimes when you get stuck, look at the refinements of the function you are using. ? do Evaluates a block, file, URL, function, word, or any other value. Arguments: value -- Normally a file name, URL, or block Refinements: /args -- If value is a script, this will set its system/script/args arg -- Args passed to a script. Normally a string. /next -- Do next expression only. Return block with result and new position. do/arg is what you are after... ; Changed to show all args are passed REBOL [Title: "Param Test" file: %param.r] either string? system/script/args [ args: parse system/script/args none foreach arg args [print arg] ][ print "No arguments passed." ] do/args %param.r reform ["List" "of" (2 + 2) "args" ] Script: "Untitled" (none) List of 4 args The above works. IMHO Depending on what I need to achieve, I would hardly ever use the do/args aproach, more commonly I would do a script and then call the functions in it, this allows me to use scripts as libraries of functions. Cheers, Allen K. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, March 16, 2000 3:48 AM Subject: [REBOL] pleh! pleh! basic reborientation needed! > I started out with much energy, and am now floundering on the simplest things. > > I cannot get *anything* to do with command line arguments to work at all. > I have tried c&p-ing examples from messages here, and they don't work. > > (Well... K.R.'s path example seemed to work for what it was worth, > and I now surround the inner part of each script with: > - > savecd: system/script/parent/path > ... > change-dir savecd > - > so I don't have to change-dir back after every do %...) > > Anyway, something as simple as... > > >> do %projects/test/params.r "doggy" > (alternately: do %projects/test/params.r doggy > or: do %projects/test/params.r [doggy] > or: do %projects/test/params.r ["doggy"]) > > params.r (just the guts, ma'am) > - > ; yeeth! just gimme the first one! > either string? system/script/args [ > args: parse system/script/args none > print args/1 > > ][ > print "No arguments passed." > ] > - > or should that be: > - > ; by this time, I really don't care if there were no params! > args: parse system/script/args none > forall args [ > print args/1 > ] > - > finally: > - > >>do %something "please!" > - > > I've tried every combination I can think of for the last hour without success. > Like using system/options/args... different looping constructs, different number > of parameters on the command line, etc. If anyone wants to observe me losing it > in detail, I can send a copy (13K) of my last session history on request. > > Going (?) nuts. > > -- > Pete Wason|"LWATPLOTG"|[EMAIL PROTECTED]|[EMAIL PROTECTED]|CUCUG|TA|PHX > > PS: This whole thing strikes me as kind of funny, since the first thing I did in > rebol was a directly interpreted one-liner that checked a webserver for its > status and sent an email if it was down -- which worked on the first try. Maybe > it was something I ate for breakfast... > >
[REBOL] pleh! pleh! basic reborientation needed! Re:
Allen Kamp wrote: > > > Hi Pete, > > > > Sometimes when you get stuck, look at the refinements of the function you > > are using. [snipped nice clear explanation] cool - I think I get it now ;-) here's another problem, which I could have sworn I've seen an example of, but now can't find: tse: read http://...blah...blah...blah. I know I can find (manually) the strings (rebol wildcards shown) Last Traded* Net Change* somewhere on this page. I need to get what * is in each case. I've tried things like: ltrade: copy/part (find tse " ") (find tse {Last Traded}) but this obviously doesn't work... prob. because I don't understand what (number series port) means here: >> help copy Returns a copy of a value. Arguments: value -- Usually a series (series port bitset) Refinements: /part -- Limits to a given length or position. range -- (number series port) /deep -- Also copies series values within the block. Thanks for your help! -- Pete Wason|"LWATPLOTG"|[EMAIL PROTECTED]|[EMAIL PROTECTED]|CUCUG|TA|PHX Get a cool electronic checking account at: https://preview.x.com/new_account.asp?[EMAIL PROTECTED]
[REBOL] pleh! pleh! basic reborientation needed! Re:
Carefully reading the documentation, it looks like this arg scheme only works when invoking REBOL, NOT from the DO command. Thinking about this, it makes sense. That is, how would DO know how many arguments (if any) to gobble up? - ; Save the following script: REBOL [ Title: "Test" Author: "Michael Jelinek" Date: 2000/03/15 File: %test.r Email: [EMAIL PROTECTED] ;for problems or changes Purpose: {Test programming ideas} ] print mold system/script/args - ; then, from the OS command line, type: rebol test.r "hey" - - Michael Jelinek -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 15, 2000 9:48 AM To: [EMAIL PROTECTED] Subject: [REBOL] pleh! pleh! basic reborientation needed! I started out with much energy, and am now floundering on the simplest things. I cannot get *anything* to do with command line arguments to work at all. I have tried c&p-ing examples from messages here, and they don't work. (Well... K.R.'s path example seemed to work for what it was worth, and I now surround the inner part of each script with: - savecd: system/script/parent/path ... change-dir savecd - so I don't have to change-dir back after every do %...) Anyway, something as simple as... >> do %projects/test/params.r "doggy" (alternately: do %projects/test/params.r doggy or: do %projects/test/params.r [doggy] or: do %projects/test/params.r ["doggy"]) params.r (just the guts, ma'am) - ; yeeth! just gimme the first one! either string? system/script/args [ args: parse system/script/args none print args/1 ][ print "No arguments passed." ] - or should that be: - ; by this time, I really don't care if there were no params! args: parse system/script/args none forall args [ print args/1 ] - finally: - >>do %something "please!" - I've tried every combination I can think of for the last hour without success. Like using system/options/args... different looping constructs, different number of parameters on the command line, etc. If anyone wants to observe me losing it in detail, I can send a copy (13K) of my last session history on request. Going (?) nuts. -- Pete Wason|"LWATPLOTG"|[EMAIL PROTECTED]|[EMAIL PROTECTED]|CUCUG|TA|PHX PS: This whole thing strikes me as kind of funny, since the first thing I did in rebol was a directly interpreted one-liner that checked a webserver for its status and sent an email if it was down -- which worked on the first try. Maybe it was something I ate for breakfast...