Mainframe Path Start learning free
Core8 min readLesson 1 of 4

Your first REXX exec

REXX is a simple, readable scripting language built into z/OS. People use it to automate the repetitive parts of mainframe work: checking datasets, running TSO commands, building reports and driving ISPF.

Where REXX runs

The smallest exec

HELLO — a member in your exec library
/* REXX */
say 'Hello, mainframe'
say 'Today is' date('W') date()
exit 0

Running it

Variables and input

Variables need no declaration and have no type; everything is a string, and numbers are strings that look like numbers. ARG reads the parameters the exec was called with, uppercased; PULL reads a line from the terminal.

Arguments and arithmetic
/* REXX */
arg hlq count
if count = '' then count = 3
total = count * 10
say 'Listing' hlq 'with' total 'lines'

Common mistakes

Leaving out /* REXX */

The member is treated as a CLIST. Always start with the REXX comment.

Forgetting ARG uppercases

ARG converts input to capitals. Use PARSE ARG to keep the case as typed.

Uninitialised variables

An unset variable's value is its own name in capitals, so typos silently become text. SIGNAL ON NOVALUE catches this.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
Decisions, loops and PARSE →