Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How do I handle an unset! item as a parameter to other words

 [1/5] from: gerardcote:sympatico:ca at: 2-Dec-2002 9:23


Hi everybody, Since I am trying to get the maximum output from the available ON-LINE help REBOL offers to me, I ask myself if there is a way to get a file from the what function, excepted from the evident way I already tried and tested - that is by modifying the source of the "what" funct. and redirecting its output from console (the original funct. uses a PRINT to show every word and its args) to a file (Write/append/lines %rebol-dict.txt to-string reduce [word " " args] ). I looked for something like using the following constructs but I got a similar error in any case :
>>write %rebol-dict-2.txt what
... a long list of the avail. words and their args follows then ... ** Script Error: write is missing its value argument ** Where: halt-view ** Near: write %rebol-dict-2.txt what
>>
I tried to look why REBOl acts like this with :
>>type? what
... a long list of the avail. words and their args follows then ... = = unset! so a function is not available as an entry to another as is. But is there a way to mislead REBOL as to think this is simply another word having a regular value to act upon ? I tried the "set" word but seems I really lack some fundamental knowledge in this area. May someone help me please ? I would be much grateful to any submitter who tries. Thanks in advance. REBOL surely has to be this DYNAMIC but how can I do it without reinventing the Wheel everytime ? Thanks, Gerard P.S. From a newcomer's pov, it seems to me that the WHAT function SHOULD appear in any other on-line HELP related word included with REBOL. For example, the first time I tried REBOL I would have liked this listed somewhere, like when a new user types HELP, or USAGE and that some hints are displayed. If I didn't discover this command by the way of the ML - I agree that I should have read and studied every cmd since the beginning from the CORE User's guide but I didn't read all yet and the letter W is at the end - I wouldn't know about this before a very long time ... If this is not added to the on-line REBOL HELP or USAGE commands, be sure to include it soon in the available docs. May be it is but it didn't took my attention soon enough and it should have been so, from my pov. Another suggestion would be to add some options to pause (or otherway control or redirect) the display of native REBOL words that display very LONG, multi-pages information to the console. Much like the way the MS-DOS "DIR" command (or the Unix "ls" command) permitted to display everything in different ways with simple refinements. Why should everybody reinvent the wheel for so common use Words ? Or at least someone should submit a library of functions related to these common taks. If nobody has done such work, I'll do my best in a near future while adapting my old knowledge to teach REBOL for newcomers. Then I'll submit this stuff for common use but it seems this is like bread and butter in my current tasks and a bit neglected in what native REBOL offers to its users, even if I understand the footprint has to be the smallset possible - it's a REAL compromise between productivity, easiness and compactness, but sometimes for very frequent tasks I personally favor the first 2 ... Thanks for listening, Gerard

 [2/5] from: jan:skibinski:sympatico:ca at: 2-Dec-2002 10:06


Hi Gerard,
> I looked for something like using the following constructs but I got a > similar error in any case :
<<quoted lines omitted: 4>>
> ** Near: write %rebol-dict-2.txt what > >>
That's the expected behaviour. Function 'what accepts nothing and returns nothing. In C or Java parlance it's return type would be 'void. It does print something on the console, but that's a side effecting operation. Other (static!) languages would spell it very clearly: Ocaml ------ what: ( ) Haskell ----- what :: IO ( ) but unfortunately Rebol does not care that much for the return types, because it can only figure them out dynamicly; that is, after executing statements or expressions. That's what the 'type? function is telling you: type? what == unset It means that there is no real object returned from the 'what function. If you want to intercept output from functions like this then you need to deal with the standard output itself. Look at the script library - consoleio.r, keyb.r, etc. Regards, Jan

 [3/5] from: rotenca::telvia::it at: 2-Dec-2002 19:28


Hi Gerard What sends it output to the console. You can use Echo to redirect it to a file: echo %file.txt what echo none
>> help echo
USAGE: ECHO target DESCRIPTION: Copies console output to a file. ECHO is a function value. ARGUMENTS: target -- (Type: file none) (SPECIAL ATTRIBUTES) catch --- Ciao Romano ----- Original Message ----- From: "Gerard Cote" <[gerardcote--sympatico--ca]> To: <[rebol-list--rebol--com]> Cc: "Gérard Côté (Sympatico)" <[gerardcote--sympatico--ca]>

 [4/5] from: gerardcote:sympatico:ca at: 2-Dec-2002 21:46


Hi Romano, You wrote :
> What sends it output to the console. You can use Echo to redirect it to a > file: > > echo %file.txt > what > echo none >
... This will probably be very useful in many situations I didn't even foresee yet !!! But for the case being, Thanks a lot Romano - this is just what I was looking for - a simple redirection (or sometimes a Unix's Tee like) mechanism. And by the fact it was already done by the Master of REBOL, so thank you too Carl for such a planning ... Regards, Gerard P.S. This has already saved my day, and I hope many more to come ! (if I can afford this expression ...) But as promised Jan, I'll also study the way consoleio.r and keyb.r are working !!!

 [5/5] from: gerardcote:sympatico:ca at: 2-Dec-2002 21:34


Hello Jan, You wrote :
> That's the expected behaviour. Function 'what accepts nothing > and returns nothing. In C or Java parlance it's return type would
<<quoted lines omitted: 14>>
> you need to deal with the standard output itself. Look at the script > library - consoleio.r, keyb.r, etc.
Thank you very much for the explanation. I'll look at these other scripts you suggest. Cheers, Gerard

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted