Using Classic REXX if Object REXX is the default REXX

[Autolink] Menu

Sometimes it's necessary to test your REXX programs under Classic REXX and under Object REXX. Therefore it would be useful to use both interpreters without rebooting each time you change the REXX interpreter.

This is possible under OS/2 if you use the following approach:

- use Object REXX as your default REXX interpreter without the Workplace Shell support (i.e., do NOT use WPSINST)!!!

- create a WPS Object for the REXX program REXXTRY.CMD with:

┌─────────────────────────┬─────────────────────────┐
│Title                    │Start Object REXX        │
├─────────────────────────┼─────────────────────────┤
│Path and filename        │*                        │
├─────────────────────────┼─────────────────────────┤
│Parameters               │/C REXXTRY.CMD           │
├─────────────────────────┼─────────────────────────┤
│Working directory        │\                        │
└─────────────────────────┴─────────────────────────┘

- create a new directory

- extract the REXX program below from this INF file and save it in the new directory with the name STARTCR.CMD

- ensure that your LIBPATH contains the entry '.;' before the entry \OS2\DLL (You need to reboot once if you must change your LIBPATH)

- copy the REXX.DLL from Classic REXX into the new directory with STARTCR.CMD (This is the DLL named CREXX.DLL in \OS2\DLL if Object REXX is currently the default REXX interpreter)

- create a WPS Object for the REXX program STARTCR.CMD with the following setup

┌─────────────────────────┬─────────────────────────┐
│Title                    │Start Classic REXX       │
├─────────────────────────┼─────────────────────────┤
│Path and filename        │*                        │
├─────────────────────────┼─────────────────────────┤
│Parameters               │/K .\STARTCR.CMD         │
├─────────────────────────┼─────────────────────────┤
│Working directory        │the directory with       │
│                         │STARTCR.CMD              │
└─────────────────────────┴─────────────────────────┘

Now you can select the REXX interpreter to use:
Start the WPS object "Start Classic REXX" if you need Classic REXX or start the WPS object "Start Object REXX" if you need Object REXX. All other programs started after one of these objects will use the REXX interpreter that is loaded.

Note that it is only possible to use one REXX interpreter at a time. To switch the REXX interpreter either from Classic REXX to Object REXX or vice versa you must first close all sessions using REXX, wait a bit and start the WPS object using the other REXX interpreter. Note also, that you must unload all DLLs using REXX (for example REXXUTIL.DLL) before switching the interpreter.

And last:

Please be aware that this method does not work in all cases!

 
/* STARTCR.CMD                                                      */
/* sample REXX cmd to start a session using Classic REXX if OO REXX */
/* is the default REXX interpreter                                  */
/*                                                                  */
/* To use this cmd you must                                         */
/* - ensure that your LIBPATH contains the entry '.;' before the    */
/*   entry \OS2\DLL                                                 */
/* - copy the REXX.DLL from Classic REXX into the directory with    */
/*   this CMD                                                       */
/* - create an Object for this CMD with                             */
/*   Path and filename = *                                          */
/*   Parameters = /K .\STARTCR.CMD                                  */
/*   Working directory: the directory with this program             */
/* - ensure that no other session using REXX is running             */
/*                                                                  */
/* Usage: STARTCR [startDir]                                        */
/*                                                                  */
/* Where: startDir = working directory to use                       */
/*                   Def.: use directory with STARTCR.CMD           */
/*                                                                  */
  parse arg StartDir

  say
  say
  say 'Starting a CMD session using the Classic REXX interpreter ...'
  say
  parse version interpreterVersion rest
  say 'The current REXX Interpreter version is ' || ,
      interpreterVersion rest

  if interpreterVersion <> 'REXXSAA' then
  do
    say '07'x
    say 'Error: Cannot load the DLL with the Classic REXX interpeter!'
    say
    say 'Hint:  Close all sessions using REXX, wait a minute and try'
    say '       again.'
    say
    '@pause'
    'exit'
  end /* if */
  else
  do
    if StartDir <> '' then
      call directory StartDir
    say 'Current working directory is "' || directory() || '".'
    say
  end /* else */
exit 0


[Back: Hints for using Object REXX]
[Next: Using Object REXX and the WPS]