Changing prompt without feedback
[1/4] from: rebol::techscribe::com at: 14-Nov-2000 11:23
> One (awkward, IMHO) way to sidestep this is with the following kludge > >> do [system/console/prompt: "Huh? " prin ""]
<<quoted lines omitted: 3>>> based on the fact that DOing a block returns the value of the last > expression in the block (and PRIN doesn't have a return value).
>> system/console/prompt: "$ " halt
$ You don't need the do and block combination. Result is the same because REBOL returns the value of the last expression of your input only, as in
>> 3 4 5 6 7 8 9
== 9 Elan
[2/4] from: joel:neely:fedex at: 14-Nov-2000 10:32
> I'm writing a script that requires setting the prompt. Trouble is when I > set the prompt rebol prints the result to the console, which is > undesirable: > > >> system/console/prompt: "new-prompt-> " > == "new-prompt-> " ; <- I don't want this line printed > new-prompt-> >
Let's interpret this properly. Evaluating the first line system/console/prompt: "new-prompt->" sets the prompt to the supplied string, and then returns the value of having done so. This is what REBOL always does with setting.
>> blort: 4
>> print blort
4 Note that the double equal sign "==" signifies that this is returning the value of the evaluated expression (which is subtly but significantly a different thing from PRINTing the value of the expression). One (awkward, IMHO) way to sidestep this is with the following kludge
>> do [system/console/prompt: "Huh? " prin ""]
Huh? blort: 3 == 3 Huh? based on the fact that DOing a block returns the value of the last expression in the block (and PRIN doesn't have a return value). However, this all begs the questions... 1) Why do you regard it as undesirable that the value is returned? 2) Have you considered that setting the prompt (as with setting *any* word or path values) does not print the result, therefore you can do it inside another piece of code? Huh? sets-prompt: func [s [string!]] [ [ system/console/prompt: s [ ; do other stuff as needed [ exit [ ] Huh? sets-prompt "What now? " What now? print "hello" hello What now? 3) Is there something else going on that makes this a problem? Hope this helps! -jn- -- ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 REBOL  foreach [order string] sort/skip reduce [ true "!" false head reverse "rekcah" none "REBOL " prin "Just " "another " ] 2 [prin string] print ""
[3/4] from: shannon:ains:au at: 14-Nov-2000 18:07
I'm writing a script that requires setting the prompt. Trouble is when I set the prompt rebol prints the result to the console, which is undesirable:
>> system/console/prompt: "new-prompt-> "
== "new-prompt-> " ; <- I don't want this line printed new-prompt-> I tried redirecting console output but:.. new-prompt-> echo %bitbucket.txt system/console/prompt: "new-prompt-> " == "new-prompt-> " new-prompt-> ...it doesn't work. Any suggestions? SpliFF
[4/4] from: jeff:rebol at: 13-Nov-2000 22:48
>> system/console/prompt: "new-prompt->" ()
new-prompt-> The empty paren creates an unset! which does not echo a result on the console. (The empty paren to create an unset! is a trick I learned from Ladislav. (-:) The last thing evaluated at the prompt or in a script is what is shown as the visible result on the console, unless it is unset!. Other REBOL functions return UNSET as well, like PRIN, HELP, or, more generally, functions that have no return value: unset? do func   == true which could also be written: DO DOES  system/console/prompt: "new-prompt->" do does  -jeff
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted