Typing in a Program

When you type in the following program, use the REXX/CICS editor for files that reside in the REXX File System (RFS).

The name of the program is HELLO EXEC (for now, assume that the file type is exec).

  1. Sign on to a CICS Transaction Server for VSE/ESA terminal by entering CESN and supplying your user ID and password when it is requested.
  2. Clear the screen.
  3. Type:
    edit hello.exec
  4. Type in the program, exactly as it is shown in Figure 4, beginning with /* REXX HELLO EXEC */. Then file it using the EDIT command:
    ====>  file

    Now your program is ready to run.

Figure 4. HELLO EXEC
/* REXX HELLO EXEC     */

/* A conversation      */
say "Hello! What is your name?"
pull who
if who = "" then say "Hello stranger!"
else say "Hello" who

Running a Program

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:

  1. The SAY instruction displays Hello! What is your name?
  2. The PULL instruction pauses the program, waiting for a reply.
  3. You type sam on the command line and then press Enter.
  4. The PULL instruction puts the word SAM into the variable (the place in the computer's storage) called who.
  5. The IF instruction asks, Is who equal to nothing?
    who = ""
    This means, "is the value stored in who equal to nothing?" To find out, REXX substitutes that stored value for the variable name. So the question now is: Is SAM equal to nothing?
    "SAM" = ""
  6. Not true. The instruction after then is not processed. Instead, REXX processes the instruction after else.
  7. The SAY instruction displays "Hello" who, which is evaluated as
    Hello 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:

  1. The PULL instruction puts "" (nothing) into the place in the computer's storage called who.
  2. Again, the IF instruction tests the variable
    who = ""
    meaning: Is the value of who equal to nothing? When the value of who is substituted, this scans as:
    "" = ""
    And this time, it is true.
  3. So the instruction after then is processed, and the instruction after else is not.