RxShell 3.1

Contents Functions external
Archive  Chapter 4 AAAA  FFFF  LLLL  QQQQ  Home
Introduction  Chapter 5 BBBB  GGGG  MMMM  RRRR  Contact
Features Chapter 6 CCCC  HHHH  NNNN  SSSS  Xedit
Chapter 3 History EEEE  KKKK  PPPP  UUUU   Sources

Work in progress - most topics don't exist.

top   Archive

The archive rxshell.zip (440 KB) should contain the following files:

rxshell.html        - this file
rxshell.rex         - old script (tested under DOS, internal constants)
rxshell.cmd         - new script (tested with OS/2, external constants)
-rxshell.cmd        - constants (incl. 1025 odd zetas with 1000 digits)

top   Introduction

RXSHELL is a REXX script in the spirit of IBM's REXXTRY, which in turn is a variant of the famous...

do forever ; parse pull LINE ; interpret LINE ; end

...one liner. REXXTRY promises SAA portability, but does not work under PC DOS 7 - maybe PC DOS 7 is no SAA platform <eg> - and has no decent command line history. For the latter you find a solution in Bernd Schemmer's "REXX Tips & Tricks". The first versions of RXSHELL were essentially variants of REXXTRY with the extensions proposed in Bernd's tips, rewritten from scratch, because this was the fastest way to understand the extensions, because I did not want to modify IBM's REXXTRY, and because I wanted something working not only under OS/2 REXXSAA, but also under Quercus REXX/Personal and PC DOS 7 REXXSAA.

I'd love to support Regina, but as long as the OS/2 version of Regina does not work with IBM's standard REXX interfaces don't hold your breath. I've tested RXSHELL (once) with Object REXX, and found no obvious problems. Object REXX has some obscure bugs at least on my Warp 3 system, therefore I stick to the classic REXX interpreter.

RXSHELL interprets the following input keys in its command line editor:

F1         RxShell help (this text)    F7         REXX info about input line
F2         quote (last) input line     F8         help info about input line
F3         exit                        F9         show REXX environment info
F4         save or load history file   F10        clear history (free memory)
F5         list of RxShell functions   F11        -/-
F6         input key mapping           F12        -/-
<- arrow   move cursor left            Ctrl <-    move to prev. word
-> arrow   move cursor right           Ctrl ->    move to next  word
END        last  character             Ctrl END   clear to last  char
HOME       first character             Ctrl HOME  clear to first char
TAB        complete line with history  BackSpace  clear prev. char
up   arrow show prev. line in history  DEL        clear next  char
down arrow show next  line in history  ESC        clear complete line
INS        toggle insert mode          Ctrl STAR  input key decoder tests

That's the output shown after pressing F1 in a text window with 16 or more lines and 80 or more columns. RXSHELL supports text window sizes with either 40..79 or more columns, and any number of lines. Normally I star-t RXSHELL with a *-program object using the parameters...

/Q /C ((mode 80,5 & echo off & ansi off & cls) >NUL ) & rxshell.cmd

...but that's a matter of taste. Please note that some OS/2 programs are very confused, if they are forced to run in a text window with less lines. It's no problem to change the text window size in a running RXSHELL, try MODE 80 25 or whatever you like. With REXXTRY and similar programs you have to quote commands, which should not be interpreted by REXX. In fact MODE 80 25 won't work as expected, if you set MODE = 'something' before, the resulting command something 80 25 most probably fails or won't do what you want. Similarly MODE 80,25 works in an OS/2 shell, but not in RXSHELL: The interpretation of MODE 80,25 causes a syntax error, comma is not allowed in REXX expressions. MODE 80,25 in RXSHELL has (almost) the same effect as LINE = 'MODE 80,25'; interpret LINE   or   interpret 'MODE 80,25'.

Quote strings not meant to be evaluated by REXX, as in LINE = 'MODE 80,25'; LINE   or   interpret '"MODE 80,25"'. If the REXX interpreter finds a valid expression like LINE outside of any REXX statement, then its value is passed to whatever controlling program as determined by say address(), here OS/2 CMD, or maybe KEDIT if you started RXSHELL under KEDIT.

Of course you would not use a variable LINE for a simple command, unless you need a long command line often and don't have a history. Just input 'MODE 80,25' or 'MODE 80 25', the OS/2 MODE command does not insist on the comma.

RXSHELL offers to quote the last input line by pressing F2. With F2 you can cycle through the most often needed quote-unquote-strings:

[REXX] Do you want this?
[REXX] 'Do you want this?'
[REXX] "Do you want this?"
[REXX] 'call Do you want this?'
[REXX] "call Do you want this?"
[REXX] Do you want this?

Press F2 until the wanted string appears, then press Enter. The variants with call are only interesting if you try to execute an external REXX program with OS/2 CMD.exe. For some very obscure reasons this interpreter knows exactly what you want without an explicit call - compare helpmsg SYS1803 - but refuses to do it. In the example you could use the REXX call instruction...

call Do you want this?

...and be done with it. Again the unquoted you, want, and this? would be interpreted by REXX, and the value of an undefined valid REXX symbol is its own upper case name - therefore the last example would call DO with argument string YOU WANT THIS?, unless a signal on novalue is in effect. RXSHELL forces signal off novalue before interpreting an input line. Otherwise you would have to quote all commands, definitely not what you expect in a command shell. If you want to see a NOVALUE condition for an input line, specify it as first instruction:

signal on novalue ; say oops

Normally say oops says OOPS, if oops is not defined, but after an explicit signal on novalue you get

[REXX] signal on novalue ; say oops

       +++ NOVALUE trap: OOPS
[  -2]

The prompt shows the last non-zero new return code rc, and negative codes generally indicate standard REXX errors. For three special conditions there is no corresponding error code, and NOVALUE is one of these special conditions. Try say errortext(2) - with REXXSAA you get an empty string. Another example:

[REXX] oops
SYS1041: Bei dem angegebenen Namen handelt es sich nicht um einen
internen oder externen Befehl, ein ausführbares Programm oder eine
Stapeldatei.
   259 *-*       oops;
       +++         RC(1041)

       +++ FAILURE trap: OOPS
       +++ (RC 1041)
       +++ see "address CMD 'helpmsg sys1041'" (F7 or F8)
[  -3]

If you're lost with this German error message shown by CMD.exe on my system try say sysgetmessage(1041) on your system. As shown RXSHELL offers to display the detailed 'helpmsg sys1041' after system errors with F7 or F8 - the latter directly executes the command, the former allows to edit the proposed command. This also works for REXX errors:

[REXX] say oops + 0

       +++ SYNTAX trap:  Bad arithmetic conversion
       +++ see "address CMD 'helpmsg rex0041'" (F7 or F8)
[ -41]

If you plan to port RXSHELL to another OS start with deleting the F7 and F8 feature - it's not essential, and you have probably better ideas for these keys.

top   Features

Some input keys are mapped by RXSHELL to simplify keyboard input, and some control characters are echoed with a special character not causing unpleasant side effects. If your browser cannot display &#9617; (used to echo most control char.s), &#9829; (hearts ^C), &#9656; (arrow pointing right ^P), &#9666; (arrow pointing left ^Q), and &#8252; (double exclamation mark ^S) you'll probably see a bunch of question marks here. Please consult the IBM 850 info about these characters. Sorry, the following F6 screenshot will be ragged if viewed with Lynx:

alt-A      mapped to d2c(224), echo Ó  Ctrl G     unchanged BEL (^G), echo ░
alt-C      mapped to ETX (^C), echo ♥  alt-G      mapped to BEL (^G), echo ░
alt-BS     mapped to BS  (^H), echo ░  shift-TAB  mapped to TAB (^I), echo ░
alt-H      mapped to BS  (^H), echo ░  alt-I      mapped to TAB (^I), echo ░
Ctrl CR    unchanged LF  (^J), echo ░  alt-CR     mapped to CR  (^M), echo ░
alt-J      mapped to LF  (^J), echo ░  alt-M      mapped to CR  (^M), echo ░
alt-P      mapped to DLE (^P), echo ▸  alt-Q      mapped to DC1 (^Q), echo ◂
alt-S      mapped to DC3 (^S), echo ‼  alt-ESC    mapped to ESC (^[), echo ░
alt-STAR   mapped to ESC (^[), echo ░  alt-[{ US  mapped to ESC (^[), echo ░
Ctrl @2    mapped to NUL (^@), echo ░  Ctrl STAR  start key decoder tests...

The general idea is to map control characters otherwise "eaten" by the keyborad driver or intercepted by RXSHELL to a corresponding combination with Alt. If you want to input say ETX ^C use Alt-C, because ^C would cause a HALT condition killing your input line.

The combination Alt-Esc works under native DOS, under OS/2 or MDOS use alt-Star or Alt plus the key labelled [{ on a US keyboard. If you want to find this key on your keyboard start the key decoder with Ctrl Star. On a German keyboard you'd find it as the combination Alt plus ü, and with other QWERT-keyboard layouts check the key following UIOP in the QWERT-row.

Ctrl Break and ^C should be shown as HALT by the RXSHELL key decoder. Press the same key (combination) twice to exit the key decoder.

top   Functions

Quercus REXX/Personal supports some essential math. functions as found in many C libraries with approximately 15 digits of accuracy. RXSHELL supports more functions and more digits. Many functions need only a handful of constants, essentially pi and e, but ln(2), sqrt(pi/4), and ln(2*pi) are also handy. In theory RXSHELL could compute these constants at its start, and whenever the NUMERIC DIGITS setting is changed.

In practice RXSHELL does compute these constants for more than 501 NUMERIC DIGITS - in the old version the limit is only 100 digits. One obvious disadvantage of recomputed constants is the speed, depending on the number of digits and the hardware RXSHELL may need minutes, hours, days, or centuries to compute its constants. Therefore the old version contains constants, and the new script reads an external file with the constants.

For five constants an external file would be overkill, but some functions (erf, gamma, and Li) need Euler's constant C0 also known as constant gamma. It's really easy to compute this constant, all you need are the values of the zeta function for odd whole numbers > 1, i.e. zeta(3), zeta(5), etc. These odd zeta values are also required to compute gamma(x) if 2*x is no whole number. It's also easy to compute zeta(3) based on the other odd zeta values starting with zeta(5). But that's more or less the end of these "simplifications" - we still need the first odd zeta values, and the computation of zeta values with many digits is excessively slow for small odd integer arguments. Therefore Euler's constant gamma and zeta(3) up to zeta(2051) (new) resp. zeta(119) (old) are loaded from an external file resp. contained in the source.

Depending on the NUMERIC DIGITS setting RXSHELL may not need all computed odd zeta values - as soon as the rounded value is 1 it would be useless to read more values from the external file. For the new version with more than 1000 constants and about 1000 digits this is an issue, reading and rounding the values needs some time. For DOS it's absolutely necessary to round the constants, because there is no memory to store thousands of unused digits.

RXSHELL determines more odd zeta values when needed, the simple algorithms are fast enough for greater integers and (internally) up to 1003 (new) resp. 200 (old) digits.

top   History

07-2003
Starting a manual (this file). Make-file to update the new archive. Replace old and new source by manual and archive on the Web sites.
06-2003
Reorganization of internal (pre-computed) constants, essentially using the list fix me with 1000 digits for the first 1025 odd zeta values. Obscure code to use the precomputed digits even for double precision removed, i.e. only 500 digits available for the user. Loading internal constants was too slow, extracted to an external file. Moved code to compute Euler's constant gamma to the self test and added it as additional external constant. Initializing NUMERIC DIGITS 500 is still too slow, but at least 500 digits are now supported by all functions, including erf, Li, and gamma.
01-2001
First release, now essentially the old script still contained in the archive, because the new script needs huge amounts of memory for the constants depending on the setting of NUMERIC DIGITS - actually it's not so extreme, but PC DOS 7 REXXSAA is limited to about 500 KB.

XHTML validator Last update: 18 Jul 2003 12:00 by F.Ellermann