Running a program
About this task
Clear the screen before running an exec. If you want
to run a program that has a file type of EXEC, you type in
REXX
followed
by its file name. In this case, type
rexx hello
on
the command line and press Enter. Try it!
Suppose your name
is Sam. Type
sam
and press Enter.
Hello SAM
is
displayed.
rexx hello
Hello! What is your name?
sam
Hello SAM
Here is what happens:
- The SAY instruction displays
Hello! What is your name?
- The PULL instruction pauses the program, waiting for a reply.
-
You type
sam
on the command line and then press Enter. -
The PULL instruction puts the word SAM into the variable (the
place in the computer's storage) called
who
. -
The IF instruction asks, Is
who
equal to nothing?
This means,who = ""
is the value stored in
To find out, REXX substitutes that stored value for the variable name. So the question now is: Is SAM equal to nothing?who
equal to nothing?"SAM" = ""
-
Not true. The instruction after
then
is not processed. Instead, REXX processes the instruction afterelse
. -
The SAY instruction displays
"Hello" who
, which is evaluated asHello SAM
Now, here is what happens if you press Enter without
typing a response first.
hello
Hello! What is your name?
Hello stranger!
Then again, maybe you did not understand
that you had to type in your name. (Perhaps the program should make
your part clearer.) Anyhow, if you just press Enter instead of typing
a name:
-
The PULL instruction puts "" (nothing) into the place in the
computer's
storage called
who
. -
Again, the IF instruction tests the variable
meaning: Is the value ofwho = ""
who
equal to nothing? When the value ofwho
is substituted, this scans as:
And this time, it is true."" = ""
-
So the instruction after
then
is processed, and the instruction afterelse
is not.