• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[Rebol School] REBOL School

GrahamC
14-Apr-2013
[1856]
Was that the abortive View development?
caelum
14-Apr-2013
[1857]
Don't know. The program dates back to 2005. Was that when the 'abortive 
View development' happened?
NickA
14-Apr-2013
[1858]
Chris is still active here - have you tried PMimg him?
caelum
14-Apr-2013
[1859]
Yes, I left a message for him. But he has not been here for a couple 
of months.
GrahamC
15-Apr-2013
[1860]
Here's usually now found on http://chat.stackoverflow.com/rooms/291/rebol-and-red
Artful
23-Apr-2013
[1861]
ok silly newbie question here.  I'm trying to run some scripts in 
rebol/view 2.7.8 which produce just console output.  I'm finding 
the output window automatically closing when the script ends.  I 
know I could fix this with a readline statement, but I'm wondering 
why the auto-close in prefs.r isn't working for me.  I'm also trying 
to run same script via dos window, using rebol.exe -ws test.r  but 
that opens an output window rather than display to the dos window. 
 I feel such a noob lol.
Gregg
23-Apr-2013
[1862x2]
Not to worry. We were all noobs once. REBOL automatically quits at 
the end of the script. If you want to keep the cosole open, put a 
HALT at the end.
REBOL, under Windows, uses its own GUI "console" window, so you have 
to trick it. Running it in CGI mode should work for you.
Artful
23-Apr-2013
[1864]
aha  ok, thanks.  I knew it was something simple.
Gregg
23-Apr-2013
[1865x2]
With REBOL, it's almost always something simple. Until you drop into 
the deep water. :-)
But someone is usually here to throw you a life preserver.
Artful
23-Apr-2013
[1867x2]
yes I am pleased the community is still going strong.
so any difference to script execution if cgi mode is used? besides 
the no output window
Gregg
23-Apr-2013
[1869]
Shouldn't be. Doc or other experts might know of subtlties though.
Endo
24-Apr-2013
[1870]
>> x: next [a b]  USE x [a: 1]  print a
** Script Error: a has no value

Why USE make 'a local on above example while X is [b] ?
Gregg
24-Apr-2013
[1871]
It works correctly under R3. R2 is obviously using the head of the 
series. You can work around it by using COPY before NEXT.
Endo
25-Apr-2013
[1872x2]
I know, it is not a big deal, I was just curious if there is a reason..
By the way, here is my sandbox function which allows only print, 
* and + words

safe-words: [print * +] 

sandbox: func [b [block!]] [use difference safe-words first system/words 
b]

>> sandbox [print 3 * 4]
12
>> sandbox [print read %test.r]
** Script Error: read has no value
DideC
26-Apr-2013
[1874]
Nice
PatrickP61
2-May-2013
[1875]
Quick Question: I'm having some trouble understanding ANY.  I thought 
it meant that you could state a condition such as IF var = ANY ["val1" 
"val2"] [do something]

But that only becomes true on the first condition, not the second. 
 Example code:


>> forever [do cmd: ask "? " if cmd = any ["quit" "q"] [print "done" 
break]]
? q
? quit
done
>>
what am I missing?
MikeL
2-May-2013
[1876x3]
The first value in your ANY block is "Quit" which is not a TRUE.
The second is "Q" which is also not a TRUE.
HELP ANY gives Evaluates and returns the first value that is not 
FALSE or NONE.
Gregg
2-May-2013
[1879]
Patrick, just do this in the console and see what you get:

any ["quit" "q"]
PatrickP61
2-May-2013
[1880]
Ok, so ANY is simply a way to pass back a value that is not false?
Gregg
2-May-2013
[1881x2]
The key part in the doc string: "...returns the first value that 
is not FALSE or NONE"
So it evaluates each value in the block you give it, and as soon 
as it hits a value that is not false or none, it returns that value. 
So, in your case, it will always return "quit".
PatrickP61
2-May-2013
[1883]
so in my case ANY ["quit" "q"] will ALWAYS return "quit" since it 
is a valid expression
Gregg
2-May-2013
[1884x2]
Correct.
So think of how to solve it other ways. ANY evaluates, so you could 
put your comparison expressions inside the ANY block. That will get 
unwieldy very fast though. How else might you do it? What is it you 
want to do (in a general sense)?
PatrickP61
2-May-2013
[1886x2]
I suppose the CASE command would be better
My goal is to simply stay in a loop, accepting all valid rebol commands 
until I quit the loop

For example, I've defined some variables to script names, and so 
when I enter the variable, it should DO those names, until quit
Gregg
2-May-2013
[1888x2]
And for the case of q and quit, and maybe others, you want to see 
if they command is in a set of commands you want to process in a 
special way, correct?
That is, you want to see if you FIND the command in a set of known 
commands and act accordingly.
PatrickP61
2-May-2013
[1890x2]
not really, it's just a quick shortcut to allow any REBOL command 
to be performed while it is in a script that is already executing.
...doing stuff...

stopping here to accept various rebol commands and looping until 
finished
...doing the rest of the script
Its a way to "pause" a running script to enter rebol commands and 
then when I'm done, get out of the loop and continue with the rest 
of the script
Gregg
2-May-2013
[1892]
Right, so you ask for the command, see if it's a command to exit 
your loop (q or quit) and DO it if not, correct?
PatrickP61
2-May-2013
[1893x2]
yep
Although, the way I have it, it should do the command no matter what 
is entered
Gregg
2-May-2013
[1895x2]
And it will, which is not what you want.
So start with that, and then add the handling for your special commands.
PatrickP61
2-May-2013
[1897]
Actually, it is.  I want it to do ANY rebol command.
Gregg
2-May-2013
[1898x3]
forever [cmd: ask "? "  do cmd]
Any command except q or quit, which should break your loop, correct?
And what about an empty command?
PatrickP61
2-May-2013
[1901x3]
Doesn't work
It just repeats what i've entered
forever [do ask "? "]  will work on some rebol commands like HELP 
or PRINT "HI" but not "Q" or "QUIT"

which is why I tried to state the condition to break out of the loop
Gregg
2-May-2013
[1904]
So if you type "quit" (no quotes) after running that, it doesn't 
quit REBOL?
PatrickP61
2-May-2013
[1905]
right