Use interactive environment
Many interpreters in the script language provide an interactive environment through which we can communicate with computers. Why is it
Interactive Environment? Because we can communicate with the computer through programming languages and let it do anything, it will immediately follow and
Give us feedback.
Run REBOL
The interpreter is easy to use. Double-click the REBOL interpreter file and you will see an article
Word window, which is a REBOL
. In general, the background color of Microsoft Windows text windows is black,
Apple Mac OS X
The background color of the text window is white. The book uses a black background to represent the window of the REBOL interaction environment.
The window contains a large amount of text information, including
. And
A blinking cursor indicates that code can be entered. You can enter the REBOL program behind the cursor.
Start the following two experiments:
••
Enter 1 + 2 and press Enter. This is a very short program.
• Enter Q or quit (Q is short for quit) and press enter to exit the REBOL.
If you follow the previous operation method, you have exited REBOL.
Interpreter. Open it again now!
We can use what-Dir to know what the current directory (DIR) path is ). The current directory is
Identify the directory. If no path is specified for the file, the file is in the current directory by default.
Windows
At the beginning, the current directory is okay, that is, the home directory of the REBOL. But for Mac
The problem is actually the user's main directory. You can use CD
Function to adjust the current directory. CD
Is to change the directory (Change
Directory.
It is worth noting that REBOL
Specifies that the file (a directory is also a file) must be prefixed with the % symbol, regardless of the Operating System
Unified adoption/
Or \ is used as the directory separator, REBOL
Always use /. %
Followed/
Indicates the absolute path.
REBOL
The interpreter window is also called the REBOL interaction environment. In the interactive environment, you will see> and =, respectively
And result prompt. As the name implies, you can enter a program at the input prompt and a prompt at the result prompt.
The execution result (that is, the return value) is displayed later ). At the end of the input prompt, We can enter a REBOL line.
Code, and then press the Enter key. This line of code is called a command line.
As shown in the following figure, the first command line is power 23 (2
), Calculate the 3rd power of 2; the second command
Create a file hello.txt with the content "hello". The third command line is "ls" to list all files in the current directory (
The fourth line of the just-established hello.txt example is to delete the hello.txt file. The Fifth command line lists the current object again.
All the files in the directory (see hello.txt.
Disappears ).
Some command lines return values in the operation process, while others do not. A simple understanding of this: for a value or query
For the purpose of the code (power, what-Dir, +), there will be a return value; but to do the main purpose of the code (write,
Ls, delete), there may be no return value.
This article is excerpted from "programming ing: everyone can learn programming ".
Dr. Cai
Published by Electronic Industry Publishing House
Book details: http://blog.csdn.net/broadview2006/article/details/7768124