SLP-REXX v1.0 LANGUAGE REFERENCE

Structured Line-Programmed REXX - Subset Interpreter

Phone: 555-0340

Introduction

Welcome to SLP-REXX, the Restructured Extended Executor for Emulator.ca Systems.

In 1979, IBM researcher Mike Cowlishaw created REXX as a scripting language that would be both easy to learn and genuinely pleasant to use. Unlike the terse syntax of earlier system languages, REXX was designed with human readability in mind. Variable names can be meaningful. Statements read like English. The language forgives casual formatting while rewarding careful structure.

What made REXX special was its philosophy: a programming language should work with you, not against you. Variables are typeless - assign a number, then a string, without declarations or conversions. Expressions evaluate naturally. And the language provides just enough structure (DO/END blocks, IF/THEN/ELSE) to write clear, maintainable programs without the ceremonial overhead of larger languages.

SLP-REXX brings this elegant design to your EC-TTY terminal. Whether you are calculating, processing text, or simply exploring programming concepts, you will find REXX a capable and forgiving companion.

What REXX Is Good For

REXX excels at tasks that benefit from clear, readable code:

This implementation includes:

SLP-REXX is line-based and executes your program when the current block is complete. Use DO/END to create multi-line blocks; the interpreter will prompt with ... until the matching END is supplied.

Getting Connected

To access the SLP-REXX interpreter, configure your modem for dial-out and issue the following command:

ATDT555-0340

Upon successful connection, you will see the REXX banner and the REXX> prompt:

CODE_FENCE_0

Interactive REPL

Now you can try REXX directly in this manual using the interactive REPL below:

SAY "Hello from REXX!"

Try these commands:

  • SAY "Hello, World!" - Display text
  • X = 10 - Assign variable
  • SAY X * 5 - Print result
  • DO I = 1 TO 5 then SAY "Count" I then END - Loop example

Program Structure

Single-Line Statements

Type a statement at the prompt and press ENTER to execute it immediately:

CODE_FENCE_0

Multi-Line Blocks

Use DO/END to create multi-line blocks. The interpreter waits for END before running:

CODE_FENCE_0

Comments

Block comments are supported with /* ... */:

/* THIS IS A COMMENT */
X = 10 /* COMMENTS CAN ALSO APPEAR INLINE */

Variables & Assignment

Typeless Variables

REXX variables are typeless and case-insensitive. Assign using =:

CODE_FENCE_0

Default Values

Uninitialized variables evaluate to their own name as a string (classic REXX behavior):

CODE_FENCE_0

String Concatenation

Use the || operator to concatenate strings:

CODE_FENCE_0

Control Flow

IF/THEN/ELSE

IF evaluates a condition and runs a statement or a DO/END block. ELSE provides an alternate path:

CODE_FENCE_0

Counted DO Loops

Use DO with a loop variable to count from start to end (optionally with BY):

DO I = 1 TO 5
  SAY I
END

DO I = 10 TO 2 BY -2
  SAY I
END

Conditional DO Loops

Use DO WHILE or DO UNTIL to repeat based on a condition:

CODE_FENCE_0

EXIT

EXIT stops execution immediately (useful for early termination inside loops or conditionals):

CODE_FENCE_0

Built-in Functions

String Functions

Function Description Example Result
LENGTH(s) Length of string LENGTH("REXX") 4
SUBSTR(s, start [, len]) Substring starting at position (1-based) SUBSTR("HELLO", 2, 3) "ELL"
WORDS(s) Count whitespace-delimited words WORDS("A B C") 3
WORD(s, n) Return word n (1-based) WORD("A B C", 2) "B"

CODE_FENCE_0

Numeric Functions

Function Description Example Result
ABS(x) Absolute value ABS(-8) 8
INT(x) Truncate toward zero INT(3.9) 3

CODE_FENCE_0

Practical Examples

These complete examples demonstrate REXX's capabilities and give you programs to try immediately.

Temperature Converter

Convert Fahrenheit to Celsius:

SAY "TEMPERATURE CONVERTER"
SAY "====================="
F = 72
C = (F - 32) * 5 / 9
SAY F || " FAHRENHEIT = " || INT(C) || " CELSIUS"

Word Counter

Count and display words in a sentence:

TEXT = "THE QUICK BROWN FOX JUMPS"
SAY "TEXT: " || TEXT
SAY "WORD COUNT: " || WORDS(TEXT)
DO I = 1 TO WORDS(TEXT)
  SAY "  WORD " || I || ": " || WORD(TEXT, I)
END

Multiplication Table

Generate a times table:

N = 7
SAY "MULTIPLICATION TABLE FOR " || N
SAY "=========================="
DO I = 1 TO 10
  RESULT = N * I
  SAY N || " x " || I || " = " || RESULT
END

Countdown Timer

A simple countdown with conditional loop:

COUNT = 10
DO WHILE COUNT > 0
  SAY COUNT || "..."
  COUNT = COUNT - 1
END
SAY "BLAST OFF!"

Fizz Buzz

The classic programming exercise:

DO I = 1 TO 20
  IF I // 15 = 0 THEN SAY "FIZZBUZZ"
  ELSE IF I // 3 = 0 THEN SAY "FIZZ"
  ELSE IF I // 5 = 0 THEN SAY "BUZZ"
  ELSE SAY I
END

Type these examples at the REXX prompt. Modify the values and see what happens. Experimentation is the best way to learn.

System Commands

The following commands are available at the REXX prompt:

Command Description
/HELP Display available commands
/RESET Clear all variables and reset interpreter state
/EXIT Disconnect from the REXX service

Pressing Ctrl+C cancels the current input and returns to the prompt.

Technical Specifications

Error Messages

Error Cause
Unexpected character: X Invalid character in input
Expected keyword X Missing required keyword (e.g., THEN, TO, END)
Expected identifier Variable name required but not found
Unexpected EOF (missing END) DO block not closed with END
Loop iteration limit reached Loop exceeded 100,000 iterations

SLP-REXX v1.0 - Emulator.ca Systems

Document Revision 1.0

Appendix A: Quick Reference Card

╔══════════════════════════════════════════════════════════════════════════╗
║  SLP-REXX v1.0 - QUICK REFERENCE                     Emulator.ca Systems ║
╠══════════════════════════════════════════════════════════════════════════╣
║                                                                          ║
║  OUTPUT:          SAY "text"           SAY variable                      ║
║  ASSIGNMENT:      name = value         X = 10                            ║
║  CONCATENATE:     str1 || str2         "HELLO" || " WORLD"               ║
║                                                                          ║
║  CONDITIONALS:    IF expr THEN stmt    IF expr THEN stmt ELSE stmt       ║
║                                                                          ║
║  COUNTED LOOP:    DO var = start TO end [BY step]                        ║
║                     statements                                           ║
║                   END                                                    ║
║                                                                          ║
║  CONDITIONAL:     DO WHILE condition   DO UNTIL condition                ║
║                     statements           statements                      ║
║                   END                  END                               ║
║                                                                          ║
║  STRING FUNCS:    LENGTH(s)            Returns length of string          ║
║                   SUBSTR(s,pos,len)    Extract substring (1-based)       ║
║                   WORDS(s)             Count words in string             ║
║                   WORD(s,n)            Return nth word (1-based)         ║
║                                                                          ║
║  NUMERIC FUNCS:   ABS(n)               Absolute value                    ║
║                   INT(n)               Truncate toward zero              ║
║                                                                          ║
║  COMMANDS:        /HELP                Show available commands           ║
║                   /RESET               Clear variables, reset state      ║
║                   /EXIT                Disconnect from service           ║
║                                                                          ║
║  DIAL: ATDT555-0340                                                      ║
╚══════════════════════════════════════════════════════════════════════════╝

Appendix B: Troubleshooting

Syntax Errors

Problem: "Unexpected EOF (missing END)"

Your DO block was not closed properly. Count your DO and END keywords - they must match. Multi-line blocks require END on its own line.

REXX> DO I = 1 TO 3
... SAY I
... END              <-- Don't forget this!

Problem: "Expected keyword TO"

Counted loops require the TO keyword. Correct syntax: DO I = 1 TO 10

Runtime Issues

Problem: "Loop iteration limit reached"

Your loop exceeded 100,000 iterations. Check your loop condition - you may have an infinite loop. Use EXIT or adjust your termination condition.

/* WRONG - infinite loop! */
X = 1
DO WHILE X > 0
  SAY X
  X = X + 1      /* X never becomes <= 0 */
END

Problem: Variables contain their own names

In REXX, uninitialized variables evaluate to their own name (uppercase). This is standard REXX behavior, not an error. Assign a value before using the variable.

REXX> SAY MYVAR
MYVAR              <-- Variable was never assigned

REXX> MYVAR = 42
REXX> SAY MYVAR
42                 <-- Now it has a value

Problem: Arithmetic gives unexpected results

Remember that REXX is typeless. If you concatenate a number with a string, you get a string. If you then try arithmetic, results may surprise you.

X = "10" || "20"    /* X is now "1020", not 30 */
SAY X + 5           /* Result: 1025 */

Connection Problems

Problem: Output appears garbled

Check your baud rate setting. SLP-REXX operates at 300-1200 baud. If characters are missing, reduce baud rate or add delays in your terminal software.

Problem: Connection drops during long computation

Some operations may exceed the modem timeout. Break complex loops into smaller segments or use intermediate SAY statements to maintain activity.

Appendix C: Glossary

Baud - The rate of signal changes per second on a communication line. For modems, often equivalent to bits per second at lower speeds.

Block - A group of statements enclosed by DO and END. Blocks execute as a single unit.

Concatenation - Joining two strings together. In REXX, use the || operator.

Iteration - One pass through a loop. Each time the loop body executes is one iteration.

REPL - Read-Eval-Print Loop. The interactive mode where you type commands and see results immediately.

REXX - Restructured Extended Executor. A scripting language created by Mike Cowlishaw at IBM in 1979.

Typeless - REXX variables have no fixed type. The same variable can hold a number, then a string, without declaration.

Start Exploring

REXX was designed to be learned by doing. The best way to understand its power is to sit down at the terminal and experiment. Try the examples in this manual, then modify them. Change the loop counts. Concatenate different strings. Write a program that does something useful to you - a tip calculator, a word game, anything that interests you.

The interactive nature of SLP-REXX means you see results immediately. There is no compile step, no build process - just type and run. This immediate feedback loop is how most REXX programmers learned the language, and it remains the best approach today.

Dial 555-0340 and say hello to REXX. It has been waiting to meet you since 1979.


SLP-REXX v1.0 Language Reference Emulator.ca Systems - DIAL: 555-0340