|View script||License||Download documentation as: HTML or editable|
|Download script||History||Other scripts by: ajmartin|
Script Library: 1219 scripts
Documentation for: cls.r
Usage document for %cls.r
1. Introduction to %cls.r
This little tidbit will define a function cls that will clear the console screen. CLS is old timer computer speak for CLear Screen.
2. cls At a Glance
Not setup is required, just do it.
3. Using %cls.r
The cls function will clear the console screen.
3.1. Running %cls.r
From the library with:
>> do http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-a-script.r?script-name=cls.ror locally with:
>> do %cls.r
Now whenver you type cls at a console prompt, or evalute this in a script, the console window will clear and put the input prompt at the top of the screen. Screen is also getting to be old-school, the console window is what is meant by screen (unless you are lucky enough to run REBOL on an old green or amber glowing monitor that doesn't have any graphics).
4. What you can learn
This script is about as short and sweet as they get, and even then, there are nuggets of knowledge to be found.
The cls function is made with does. does is a shortcut for defining functions that don't take any arguments or use any local variables.
4.2. prin versus print
prin does the same thing as print without a carriage return and line feed or even a space. Carriage return, line feed is really old typewriter speak. REBOL uses the expression newline. So prin newline is the same as print . I had to use the empty block for that example, because print and prin want some form of argument.
>> print ** Script Error: print is missing its value argument ** Near: print >>prin is really good at building up a sequence of output with fine control, where print is just really good.
>> prin 123 prin 456 prin 789 123456789>>Compared to
>> print 123 print 456 print 789 123 456 789 >>Note the former example is even more compressed than
>> prin [123 456 789] 123 456 789>>becase the whitespace around the 456 is actually part of the block! that is passed to prin in this case. It's built into the nature of block!. Something you can see if you try
>> [123 456 789] == [123 456 789]
Special characters in REBOL string! and char! are usually escaped with the caret ^ symbol. In this case, (page) is the voodoo computer code for start a new page. Well it used to be voodoo, ASCII 12, but REBOL is nice enough to just use the word (page). And REBOL has a high level name for this special character code as well. newpage.
>> help newpage NEWPAGE is a char of value: #"^L" >>Please see Strings in the Core Manual for more details. And while you are at it, check out Terminal Output Sequences for even more things you can do with prin and the console.
So this script could have defined cls as prin newpage
5. What can break
Nothing to break here, well unless you are running REBOL on some weird system that doesn't know about "start a new page", in which case you'll probably be talking to the computer as it creates 4 dimensional holograms of this document and cls.r may not be that useful anyway,