This lab is intended to give you some familiarity with the REXX scripting language. REXX is the easiest programming language I have encountered. It is used in the mainframe world to script a lot of repetitive tasks like creating datasets and performing backups. Knowing some REXX basics is essential to work in a mainframe environment. You can find enough information to do this lab in the REXX tutorial in the REXX Stuff section in Course Materials.
REXX is what’s called a “weakly typed” language, a language where you don’t declare the data types of the variables you use (unlike Java and C++ which are “strongly typed” languages). REXX is also interpreted, meaning it executes line by line of the source code. You can also compile REXX, but we can talk about that later.
On the mainframe, you need to have this line at the top of each of your REXX scripts (and it must be the first line):
/* REXX [and some other comments here] */
The simplicity of the syntax can be seen in the tutorial. A very simple REXX program prompts the user for his or her name, uses it in an output message:
The command “pull” acts like Scanner in Java, it takes in input from the keyboard and stores it in
a variable.
1. Using the steps outlined in earlier labs, add five new members to the dataset YOURID.LANG.SOURCE. Name them MYREXX1 through MYREXX5.
2. For each one, add some text in the member before you save it with F3 or type SAVE at the command line to stay in the member edit mode.
3. After you have created the members, you are to put some REXX code in them. When you retrieve the member, put i[x] to the left on any line in the file with text (as shown below), and this will insert x number of lines in the file (in the case below 20 lines are inserted) If you have gone through the ISPF tutorial, you know how to do this..
4. Then enter your REXX code. You will notice that you must use the arrow key to go up and down lines of text. ENTER prepares the member to be saved and is not used for navigation. F3 saves and exits the member SAVE on the commad line saves and lets you continue to edit the member.
5. Once your program (which is a member to the dataset) is saved you can run it. To run your program, at the command line you enter:
TSO EX ‘FULLY QUALIFIED PROGRAM NAME AND MEMBER’
ex: TSO EX ‘KC03A38.LANG.SOURCE(MYREXX1)’ [note the single quotes]
You can select this command with the cursor and copy it to the clipboard (ctrl-c) and then retrieve it via (ctrl-V) (while on the command line).
To delete a single line of text, just place a “d” to the left of the line and press ENTER
To delete a block of text place dd at the beginning and the range you want to delete and a dd at the end of the block you want to delete.
6. Create 5 members that each do one of the following: a) Put some hardcoded text in a member (not using a variable) and output that text to the screen; b) create a REXX program that assigns integers into two variables (hardcoded in the program and not entered by the user), then performs some arithmetic function on them (add, subtract, etc) and outputs the result to the screen (you assign the value to the variables manually and not from the keyboard); c) Similar to problem 2, but this time you use the keyboard to read the values into the variables and perform the same arithmetic function and output the result – USE THE PULL FUNCTION; d) Prompt the user to enter some text from the keyboard and output this text to the screen with a message (any message will do, use the PULL function); e) Write a very simple IF statement that tests a condition and continues the program based on that decision.
YOU WILL UPLOAD: 1) Screenshots of each of your program’s source code; 2) screenshots of the result of each of your program’s execution; 3) A screenshot of the YOURID.LANG.SOURCE dataset with members MYREXX1 through MYREXX5 showing. 4) a 100 or more word write-up of what you have done. Make sure each of your screenshots is labeled with what it is displaying.