[REBOL] Re: Changing prompt without feedback
From: joel:neely:fedex at: 14-Nov-2000 10:32
[rebol-bounce--rebol--com] wrote:
> 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
== 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 ""