REXX Tips & Tricks:REXXUTIL functions
This section contains hints about the functions from the DLL REXXUTIL.
Using REXXUTIL
If you're using REXXUTIL very often and your PC has enough memory (8 MB or more), you should load REXXUTIL in the STARTUP.CMD.
Example for STARTUP.CMD:
/* Important: STARTUP.CMD must be a REXX program to load REXXUTIL! */ call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs" call SysLoadFuncs exit 0
Using REXXUTIL if booted from diskette
If you've booted OS/2 from diskette, you can use REXXUTIL in the following circumstances:
- The stub program to load the REXX support is BOS2REXX.EXE
- The OS/2 DLLs normally in the directory \OS2\DLL are accessible through the LIBPATH. Of course, these DLLs won't fit on a diskette. But they may be on a hard disk or a codeserver.
- And last you must load each function from REXXUTIL by hand with RxFuncAdd. You can't use SysLoadFuncs if booted from diskette!
You can't use the WPS related functions from REXXUTIL if booted from diskette, but mostly all other functions work fine. For example I've tested the following functions:
SysCls SysCurPos SysCurState SysDriveInfo SysDriveMap SysGetKey SysMkDir SysOS2Ver SysRmDir SysTempFileName SysTextScreenSize
Note: see also the DLL CLTRUTIL included in the OS/2 WARP Server / OS/2 WARP Connect See also New REXXUTIL functions in Object REXX.
Hints for REXXUTIL functions
The functions to work on the macro space
The new REXXUTIL DLL provided with Object-Oriented REXX contains some functions to work with the macro space (see New REXXUTIL functions in Object REXX). These functions return the following error codes:
- okay, no error
- Not enough memory
- Macro not found
- Extension required
- Macro already exist
- File error
- Signature error
- Sourcefile not found
- Invalid position
Some further hints for these functions: � SysAddRexxMacro can only load one macro from a REXX cmd file at a time. You can't load a tokenized REXX program into the macro space using this function. SysAddRexxMacro overwrites an existing macro. The file with the REXX macro must have an extension -- SysAddRexxMacro doesn't find files without an extension.
�SysLoadRexxMacroSpace can only load an image that was previously saved with �SysSaveRexxMacroSpace. SysLoadRexxMacroSpace works only if the macro space is empty (thus you can't concenate two or more images in the macro space but AFAIK the number of macros in the image is not limited).
There's no function to get a list of all existing macros in the macrospace.
(see also LoadMac.cmd)
The function SysCLS()
The function �SysCLS clears the screen using the default colors. To clear the screen with non-default colors (set with ANSI ESC sequences) you must use the OS/2 command �CLS.
Source: John Seitz
The function SysCopyObject()
In theory you can use the function �SysCopyObject to copy a file with a long name from an HPFS formatted drive to a FAT formatted drive. In real life it works sometimes and sometimes not. This seems to be a bug.
�SysCopyObject does not overwrite an existing file.
(see also Copy a file from HPFS to FAT and vice versa for a workaround)
The function SysCreateObject()
�SysCreateObject does not support the object settings database DATABASE.DAT in the directory \OS2\INSTALL.
---
You cannot use the �SysCreateObject parameter title to change the title of an existing object. You must use the setup string keyword TITLE to do this.
---
�SysCreateObject does not replace an existing object when a caret is used in the object title to represent a new line character. Example.:
/* Create an object and update it */ call RxFuncAdd "SysLoadFuncs", "REXXUTIL", "SysLoadFuncs" call SysLoadFuncs do 2 call SysCreateObject "WPProgram" ,, "Title^with Caret" ,, "<WP_DESKTOP>" ,, "EXENAME=C:\OS2\CMD.EXE;PROGTYPE=WINDOWABLEVIO;" ,, "U" end /* do 2 */
This code should create an object on the desktop in the first round and update that object (with the same settings) in the second round. But instead of that, it creates two objects on the desktop. To avoid this, either don't use a caret in the title of an object or. better yet, always create objects with an object ID.
(Source: APAR PJ17176)
---
Be aware that using the function �SysCreateObject with the last parameter set to Replace will destroy the object and all shadows of the object before recreating it (without recreating the shadows)!