Jump to content

The REXX/imc Tutorial: Difference between revisions

From EDM2
mNo edit summary
mNo edit summary
Line 10: Line 10:
* I More advanced information can be found in rexx.summary (bare details of each command and builtin function, with a list of differences from standard Rexx) and rexx.ref (technical details of every aspect of this Rexx implementation).
* I More advanced information can be found in rexx.summary (bare details of each command and builtin function, with a list of differences from standard Rexx) and rexx.ref (technical details of every aspect of this Rexx implementation).
* O More information is available in the OS/2 help system.  For example, typing "help rexx signal" will give the syntax of the Rexx "signal" instruction.
* O More information is available in the OS/2 help system.  For example, typing "help rexx signal" will give the syntax of the Rexx "signal" instruction.
==Creating a Rexx program==
Many programmers start by writing a program which displays the message "Hello world!".  Here is how to do that in Rexx...
 
I Write a file called "hello.rexx" containing the following text.  Use any
I text editor or simply `cat' the text into the file.
O Write a file called "hello.cmd" containing the following text.  Use any
O text editor (for example, E).
Note that the text, as with all example text in this guide, starts at the first indented line and ends at the last.  The four spaces at the start of each line of text should not be entered.
 
      /* This program says "Hello world!" */
      say "Hello world!"
 
This program consists of a comment saying what the program does, and an instruction which does it.  "say" is the Rexx instruction which displays data on the terminal.
 
The method of executing a Rexx program varies greatly between implementations.
I Here is how you execute that file using REXX/imc:
I
I    rexx hello
I
I Notes about this command: rexx is the name of the interpreter.  In order
I for this command to work, the interpreter must lie on your current PATH.
I If you require more information about this then you should contact the
I person who installed REXX on your system.
I
I The word "hello" which comes after the command "rexx" is the name of your
I program.  Ordinarily, the interpreter adds ".rexx" to the name you give in
I order to construct the name of the file to execute.
I
O Here is how you execute that file on OS/2:
O
O    hello
O
When you execute your first Rexx program using the method detailed above, you should see the message "Hello world!" appear on the screen.

Revision as of 21:15, 7 August 2012

by Ian Collier

Introductory text

Note: some of the information in this file is system-specific, though most of it pertains to every implementation of Rexx. Lines containing implementation-specific information are flagged with letters in column 1. The letter "I" denotes information for REXX/imc. I have also started adding information about OS/2 Rexx, which will be flagged with "O" in column 1. I hope it is not too confusing to see some sections written twice, once for each system. The file is designed so that if you run it through "egrep '^(x| |$)'|cut -c3-" (where x is the desired letter) then it should still make sense and cut out the flag letters. Doing this will select one of the following lines indicating which system was selected; the characters to the left of this paragraph will make sure it gets deleted when that happens.

  • I This file describes REXX/imc.
  • O This file describes OS/2 Classic Rexx (which is also pretty much compatible with the OS/2 Object Rexx interpreter).
  • I More advanced information can be found in rexx.summary (bare details of each command and builtin function, with a list of differences from standard Rexx) and rexx.ref (technical details of every aspect of this Rexx implementation).
  • O More information is available in the OS/2 help system. For example, typing "help rexx signal" will give the syntax of the Rexx "signal" instruction.


Creating a Rexx program

Many programmers start by writing a program which displays the message "Hello world!". Here is how to do that in Rexx...

I Write a file called "hello.rexx" containing the following text.  Use any
I text editor or simply `cat' the text into the file.
O Write a file called "hello.cmd" containing the following text.  Use any
O text editor (for example, E).

Note that the text, as with all example text in this guide, starts at the first indented line and ends at the last. The four spaces at the start of each line of text should not be entered.

     /* This program says "Hello world!" */
     say "Hello world!"
 

This program consists of a comment saying what the program does, and an instruction which does it. "say" is the Rexx instruction which displays data on the terminal.

The method of executing a Rexx program varies greatly between implementations.

I Here is how you execute that file using REXX/imc:
I
I     rexx hello
I
I Notes about this command: rexx is the name of the interpreter.  In order
I for this command to work, the interpreter must lie on your current PATH.
I If you require more information about this then you should contact the
I person who installed REXX on your system.
I
I The word "hello" which comes after the command "rexx" is the name of your
I program.  Ordinarily, the interpreter adds ".rexx" to the name you give in
I order to construct the name of the file to execute.
I
O Here is how you execute that file on OS/2:
O
O     hello
O

When you execute your first Rexx program using the method detailed above, you should see the message "Hello world!" appear on the screen.