[USflag] The American Programmer [USflag]
Home Programming Books for Computer Professionals Privacy Terms
           Home   > Programming   > Just Enough   > Just Enough REXX
           Home   > Programming   > Manuals   > REXX Manuals   > Just Enough REXX

Books on REXX

REXX Manuals

REXX Reference Book

REXX Programming Book for TSO



The Joy of

 

REXX

 

 

REXX Tutorial

 


The purpose of this tutorial is to get you started with REXX when there is no other way - you don’t have time to go to a class, don’t want to buy a complete book on it and try to find the things you need to know.

This is nowhere near being complete. It just gets you going. For the complete story, contact me about courses in REXX. It’s just a taste of REXX. Start using it. Enjoy it.

REXX is an interpreted language found in several environments, such as:

Mainframe

MVS or OS390

VM/CMS

CICS

DOS/VSE

Midrange

AS400

Other

OS/2

Windows

DOS

It is a high level procedural language. It is on the same level as procedural languages such as COBOL, FORTRAN, PLI and C.

It is a complete programming language and includes facilities for reading and writing files, although it is limited to the simplest file structure: ordinary sequential files.

Its strength lies in its ability to do string manipulation, the simplicity of its logic structures and in the presence of many built-in functions that take the place of complex instructions.

It is often used to execute operating system commands under the control of its logic.

It is generally used without compilation, so this limits its execution speed; however this will be offset by the speed of development.

This short paper will talk about the following REXX features of REXX on TSO and CMS:

The initial comment

SAY to display on the terminal

The variable

PULL to accept input from the terminal

DO for looping

EXIT to end your program

Passing commands to TSO or CMS

For the rest, you can refer to my new REXX Reference book, available from MVS Training (800) 356 9093 or http://www.mvs-training.com.

Go to my web page: http://theamericanprogrammer.com. You’ll find information there about REXX, my REXX Reference book, other REXX books that you can order from Amazon.com, downloads and tutorials, setting up to execute REXX, REXX under DOS/VSE, REXX on the AS/400.


Table of Contents

 

 

Setting up to execute a REXX program under TSO/ISPF. 4

Setting up to execute a REXX program under VM/CMS. 5

The Initial Comment 6

SAY - Display on the Terminal 7

Variables 8

PULL - accept input from the terminal 9

DO for looping 10

EXIT to End Your Program 11

Passing Commands to TSO 12

Passing Commands to CMS 13

 

 

 

 

 

 

 

 


Setting up to execute a REXX program under TSO/ISPF.

Create a library or PDS using ISPF option 3.2.

Name:

Its name should end in the type qualifier EXEC,

although this is not a requirement.

Example: ‘userid.REXX.EXEC’

Attributes:

The library should be defined as 80 character record length,

record format FB unless your company has other requirements.

Using the ISPF Editor (option 2) create a member in your REXX library

name it, as an example TESTREXX

type in a short program in REXX,

The following is an example:

/* REXX TESTREXX */

SAY "HELLO THIS IS A REXX PROGRAM"

Type SAVE on the command line.

Make TSO aware of your REXX library.

Type this on the command line:

TSO ALTLIB ACTIVATE APPL(EXEC) DA(‘userid.REXX.EXEC’)

You will need to do this once every time you log on to TSO

and once after you do a "split screen", in the new screen.

Execute your program

Type this on the command line of any ISPF panel,

including the editor:

TSO %TESTREXX

or whatever other member name you used in your REXX library.

The program should execute.

If three asterisks appear on the screen, press ENTER to clear them.

More Information

You can obtain more information about setting up to execute REXX on TSO

at this Web address:

http://theamericanprogrammer.com/programming/rexxsetp.shtml


Setting up to execute a REXX program under VM/CMS.

Using XEDIT create a file to that will contain your program. It will be on your "A" or primary read/write disk.

Name: a two part name.

the first part is up to you, use TESTREXX as an example

the second part must be EXEC

Type this from the READY prompt of CMS or on the command line of the FILELIST (or many other panels)

XEDIT TESTREXX EXEC

Type in your program, for example:

/* REXX */

SAY "HELLO"

An initial comment is required to distinguish REXX. From :EXEC and EXEC2.

Type SAVE on the command line of the editor. You do not need to leave the editor now.

To execute the program,

type CMS TESTREXX on the command line while in the editor.

type TESTREXX at the ready prompt

 

 

 

 


The Initial Comment

For REXX to work in all environments start your program with a REXX comment. The minimum comment required is /* REXX */ starting in column 1 of the first physical line of your program. Other words are allowed inside the comment as well. The ending delimiter, */, may be placed on a different line from the first.

Simplest example:

/* REXX */

SAY "HELLO"

Example with longer comment:

/* REXX program "TESTREXX" to illustrate

whether REXX works or not

*/

SAY "HELLO"

 


SAY - Display on the Terminal

REXX is above all simple. The way to display information on the terminal is with the SAY verb. Anything after the word SAY on the same line will be displayed.

Displaying a literal character string, or constant:

SAY "HELLO THERE"

Arithmetic:

SAY 1 + 1

REXX will gladly do arithmetic on the SAY. Just don’t put the arithmetic operation in quotations!

Variables:

(The next section will describe variables.)

NAME = "SUE"

SAY NAME

 


Variables

REXX makes using variables easy. There is no variable declaration or definition. Consequently there is no datatyping: all REXX variables may contain all types of data.

You first use a variable by assigning it a value.

Assigning a literal value:

NAME = "SUE"

Assigning another variable:

FIRST_NAME = NAME

Doing arithmetic:

TOTAL = 1 + 1

For REXX to see and interpret a variable, revealing what is contained in the variable, the variable must not be in quotations:

SAY NAME


PULL - accept input from the terminal

 

Use PULL with a variable to read in something you type at the terminal. You should place a SAY before the PULL so the user knows what to type in.

SAY "PLEASE TYPE IN YOUR NAME"

PULL NAME

PULL will convert to upper case.


DO for looping

DO allows you to repeat an instruction or several instructions. It can be used to initialize and increment a variable, and continue the loop until the variable is incremented to a certain value. This is equivalent to BASIC’s FOR loop, COBOL’s PERFORM, and most other languages’ DO.

This example will initialize the variable INDEX to 1, increment it by 1 and continue looping until INDEX is greater than 10. While inside the loop it will display the variable I. Running this will produce the numbers 1 through 10.

DO I = 1 TO 10

SAY I

END


EXIT to End Your Program

The verb EXIT will end your program. It is not needed if it would be the last line in your program. It is needed if some other code, such as a subroutine follows the logical end of the program.

 

SAY "PLEASE TYPE IN YOUR NAME"

PULL NAME

SAY NAME

DO I = 1 TO 10

SAY I

END

EXIT

 

 


Passing Commands to TSO

For a discussion of TSO commands, get my paper TSOCMDS at: http://theamericanprogrammer.com/programming/justenuf.shtml

To pass a TSO command to TSO, just place the TSO command first on a line, in quotations.

Here is an example of a very simple TSO command: LISTCAT

It will display a list of catalogued files whose name begins with your TSO userid.

Placed inside of a REXX program it would look like:

/* REXX */

"LISTCAT"

The quotations around LISTCAT are optional in this case due to its simplicity. However you will normally put your TSO commands inside of quotations. This avoids having REXX try to interpret things it shouldn’t be interpreting. The next example will illustrate:

/* REXX */

"SEND ‘HELLO’ USER(TSOUID2)"

It is passing the TSO command SEND ‘HELLO’ USER(TSOUID2) to TSO. TSO understands this command; REXX doesn’t. To keep REXX from trying to understand you place it in quotations. Then REXX treats it as a literal and will not try to interpret it.

It gets a bit more interesting when you have a variable in the TSO command and you do want REXX to interpret the variable. In this case, leave the variable out of the quotations but keep the rest inside.

/* REXX */

USERID = "TSOUID2"

"SEND ‘HELLO’ USER("USERID")"

Although it is confusing to the eye, the variable USERID is outside of quotations and so REXX will see it and interpret it, changing it to its value (TSOUID2) and passing the entire line, as it sees it, to TSO.

It will pass SEND ‘HELLO’ USER(TSOUID2) to TSO.


Passing Commands to CMS

 

To pass a CMS command to CMS, just place the CMS command first on a line, in quotations.

Here is an example of a very simple TSO command: ERASE JUNKDATA DATA A1

It will display a list of catalogued files whose name begins with your TSO userid.

Placed inside of a REXX program it would look like:

/* REXX */

"ERASE JUNKDATA DATA A1"

The quotations around this command are optional in this case due to its simplicity. However you will normally put your CMS commands inside of quotations. This avoids having REXX try to interpret things it shouldn’t be interpreting. The next example will illustrate:

/* REXX */

"MSG * HELLO"

It is passing the CMS command MSG * HELLO to CMS. CMS understands this command; REXX doesn’t. To keep REXX from trying to understand you place it in quotations. Then REXX treats it as a literal and will not try to interpret it.

It gets a bit more interesting when you have a variable in the CMS command and you do want REXX to interpret the variable. In this case, leave the variable out of the quotations but keep the rest inside.

/* REXX */

MESSAGE = "HELLO"

"MSG * " MESSAGE

Although it is confusing to the eye, the variable MESSAGE is outside of quotations and so REXX will see it and interpret it, changing it to its value (HELLO) and passing the entire line, as it sees it, to CMS.

It will pass MSG * HELLO to CMS.

 

 

About this series.

Sometimes you need just enough information so that you can do something - it gets you started when you don’t have time to learn everything. Get all the others in the series at: Justenuf Other Books for professionals: REXX Reference All REXX verbs, keywords, and built-in functions as found in MVS, VM/CMS and OS/2. Order from MVS Training (800) 356 9093.MVS Training The REXX Language on TSO How to use REXX on TSO. Information, ordering at: REXX ISPF Services: Using the Dialogue Manager with REXX How to create ISPF panels on TSO. Examples in REXX. Information, ordering at:ISPF Services You will find a large selection of mainframe books at:Books. You’ll find manuals on TSO, JCL, REXX, COBOL, DB2 at:Manuals.

 

Top of Page





























































































































































































List of books on REXX and other mainframe topics

[Books Computer]

Home Programming Books for Computer Professionals Privacy Terms Contact |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |

[link page]