REXX (Restructured Extended Executor) is a programming language that was developed in the late 1970s. It is a high-level programming language that is easy to learn and has a simple syntax. It is mainly used on IBM mainframe computers, but it can also be used on other platforms like Windows, Linux, and macOS. In this blog post, we will cover the basics of REXX programming language with examples.
REXX Language Basics:
Comments are used to explain the code and are ignored by the REXX interpreter. In REXX, comments start with an asterisk (*) and continue until the end of the line.
/* This is a comment */
Variables are used to store values that can be used later in the program. In REXX, variables are not declared with a specific data type. Instead, the data type of a variable is determined when a value is assigned to it. Variables in REXX start with an alphabetic character and can include alphanumeric characters and underscores.
myVar = "Hello World!"
- Arithmetic Operators:
Arithmetic operators are used to perform mathematical operations. In REXX, the following arithmetic operators are supported:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Exponentiation (**)
- Modulo (%)
x = 5 y = 2 z = x + y /* z = 7 */
- Comparison Operators:
Comparison operators are used to compare two values. In REXX, the following comparison operators are supported:
- Equal to (==)
- Not equal to (= or ==)
- Less than (<)
- Less than or equal to (<=)
- Greater than (>)
- Greater than or equal to (>=)
x = 5 y = 2 z = x > y /* z = 1 (True) */
- Conditional Statements:
Conditional statements are used to execute different code based on a condition. In REXX, the if-then-else statement is used for this purpose.
x = 5 y = 2 if x > y then say "x is greater than y" else say "y is greater than x"
Loops are used to execute a block of code multiple times. In REXX, the do-while loop is used for this purpose.
x = 1 do while x < 5 say x x = x + 1 end
Functions are used to perform specific tasks in a program. In REXX, functions can be defined and called like this:
/* Define a function */ myFunc: say "Hello from myFunc" /* Call the function */ myFunc
- String Manipulation:
String manipulation functions are used to manipulate strings. In REXX, the following string manipulation functions are supported:
- Concatenation (||)
- Length (length())
- Substring (substr())
- Search (pos())
- Replace (overlay())
/* Concatenation */ a = "Hello" b = "World" c = a || " " || b /* c = "Hello World" */ /* Length */ len = length(c) /* len = 11 */ /* Substring */ substr = substr(c, 1, 5) /* substr = "Hello" */ /* Search */ pos = pos(c,
When to use REXX in Mainframe
REXX is a powerful scripting language that is commonly used on IBM mainframes. Here are some scenarios where REXX can be used on a mainframe:
- Batch Processing:
REXX can be used for batch processing on mainframes. Batch processing refers to running programs in a batch mode, without user intervention. REXX scripts can be used to automate batch processing tasks, such as data processing, report generation, and file transfers.
- System Management:
REXX can be used for system management tasks on mainframes. This includes tasks such as monitoring system performance, managing system resources, and automating system backups.
- Application Development:
REXX can be used for application development on mainframes. REXX scripts can be used to automate testing, debugging, and deployment of mainframe applications.
- Data Manipulation:
REXX can be used for data manipulation tasks on mainframes. REXX scripts can be used to extract data from mainframe databases, transform data, and load data into other systems.
- GUI Automation:
REXX can be used for automating tasks in mainframe GUI environments. REXX scripts can be used to simulate user input, automate repetitive tasks, and navigate through complex mainframe interfaces.
In summary, REXX is a versatile scripting language that can be used for a wide range of tasks on IBM mainframes. It can be used for batch processing, system management, application development, data manipulation, and GUI automation.