## REXX support in Kermit 95

Kermit 95 has provided an interface to the REXX scripting language on IBM OS/2 since the release of OS/2 C-Kermit 5A(190) in October 1994. As of Kermit 95 v3.0, REXX is also now available on certain versions of Windows too.

Why would you want to use REXX from within Kermit 95? Reasons might include:

- Easier-to-use math functions
- Access to functionality provided by REXX extensions
- Add your own functions to Kermit 95's script language
- On OS/2, running a REXX program without the overhead of starting a command shell
- Kermit/2 access to additional OS/2 specific functionality (e.g. create WPS objects, perform directory searches, ...)

Kermit 95's REXX programming interface consists of the single command, REXX. `REXX <command>` executes the given REXX command, for example:

      REXX SAY "Hello"

or:

      REXX RETURN "Goodbye"

or:

      REXX CALL filename [ text ]

which executes a REXX program from the given file. The text, if any, is passed to the REXX program, where it is available as ARG(1).

A REXX command or program invoked via Kermit 95's REXX command can also execute Kermit 95 commands from within REXX procedures that are invoked via Kermit 95's REXX CALL command, by enclosing them in single quotes, for example:

      'set parity none'
      'return \v(parity)'
      say rc

The RETURN value from the REXX command or program is available in the Kermit 95 variable \v(rexx). Set this by including a `RETURN <value>` command in your REXX command or program.

There are three types of functionality provided in the Kermit 95/REXX interface:

1. Ability to execute a REXX command line.
2. Ability to execute a REXX command file.
3. Ability to call Kermit 95 commands from a REXX program that is executing under Kermit 95.

Let's say you want to execute a one-line REXX program from within Kermit 95. You would use the Kermit 95 "REXX" command. The format of the command is:

      rexx rexx-command

where "rexx-command" is everything after the keyword REXX to the end of the line. A simple example:

      Kermit/2> rexx say "hello"

executes the REXX command SAY with the parameter "hello", which prints the word "hello" on your screen.

Another example, returning a value from REXX:

      Kermit/2> rexx return 4 * 4

the REXX command "return 4 * 4" calculates the value "16" and returns it to Kermit 95. Kermit 95 stores the return value from the last REXX command in \v(rexx):

      Kermit/2> echo \v(rexx)
      16
      Kermit/2>

Let's say you want to execute a series of REXX commands, but you don't want to create a REXX command file:

      Kermit/2> rexx say "hello"\13 return 0

This prints the string "hello" and then returns the value "0" to Kermit 95. Notice that \13 (Carriage Return, Ctrl-M) was placed between the commands. This is necessary because REXX expects to find each command separated by a return character just as if it was being read from a file.

To execute a REXX command file, use:

      Kermit/2> rexx call oofa.cmd

where "oofa.cmd" is the name of your REXX command file.

Now let's say you want to gain access to a Kermit 95 variable value from within a REXX program, change a Kermit 95 setting, or execute a Kermit 95 command. You could alter your program so it is called in separate parts from a Kermit 95 TAKE file or macro. But there is a better way. Just include the Kermit 95 command in your REXX program. For example, you want to set Kermit's parity from within your REXX program:

      /* Beginning of REXX program file */
      set parity "none"

Let's say you want to set a REXX variable to the value of a Kermit 95 variable:

      'return \v(parity)'
      parity = rc

Notice the single quotes around and the "return" command before the Kermit 95 variable statement. REXX passes the quoted statement to Kermit 95 for evaluation. Kermit 95 interprets the command and returns to REXX the value of the parity variable. This value is then stored in the REXX special variable RC. RC stores the return value of all non-REXX commands. The next statement assigns the value of REXX variable RC to the REXX variable parity.

### Limitations

At this time there are a number of limitations in Kermit 95s REXX support. Some of these may be addressed in future releases:

- The REXX interface is only available on IBM OS/2, and Windows XP or newer on an x86 or x86-64 processor.
- On Windows, only the Regina REXX implementation is supported. Object REXX uses a different interface making it difficult to support both. On IBM OS/2, the system REXX interpreter is used.
- The console I/O functions in regutil.dll (such as RxMessageBox, SysGetKey, etc) are not supported in K95G at this time.
- The charin()/linein()/charout()/lineout() built-in functions do not work in K95G at this time.
- REXX scripts containing Kermit 95 commands can not be run with a normal REXX interpreter - they must be run from within Kermit 95.

Click Back on your Browser's Toolbar to return.