[Is your keyboard burning?]
the REXX Files- by Dr. Dirk Terrell

One of the nice things about the REXX implementation on the OS/2 platform is its integration with the operating system. This makes it possible to perform a variety of operations such as creating WPS objects, reading and writing extended attributes of files, and reading and writing .ini files. Most of these functions are contained in the REXXUTIL library that comes with OS/2 REXX.

There are many functions in the REXXUTIL library, but the one we will make use of this month is SysCreateObject. There are times when you need to be able to launch a DOS application from a REXX program, but the application needs particular DOS settings. You could change the default settings for your DOS shell, but that may not be practical. Besides, OS/2 users expect their operating system to accommodate their needs and not vice-versa. Using the SysCreateObject function, you can start a DOS program with the necessary settings.

To be able to use any of the REXXUTIL functions, the first thing you have to do is load the library. This is accomplished with the RXFuncAdd function. The syntax is:

rc=rxfuncadd('SysLoadFuncs','RexxUtil','SysLoadFuncs')
call sysloadfuncs

Since I make copious use of the REXXUTIL library, I have created a REXX program with the above two lines in it and placed it in my Startup folder so that I don't have to worry about putting those lines in every REXX program. Of course, if you are writing a REXX program to be distributed, you should have those lines in the program somewhere before any REXXUTIL functions are called.

Now we're ready to make use of SysCreateObject. Basically what we want to do is create what is known as a transient object. As you might guess, a transient object is one that exists for a while, and is then destroyed. The object that we want to create is a DOS session running our DOS application. The WPS uses object ID's like <WP_DESKTOP> to identify objects. For transient objects, we need to use <WP_NOWHERE>. To launch our DOS application, we use SysCreateObject to create an object in <WP_NOWHERE> pointing to our DOS executable. The syntax of SysCreateObject is:

rc=SysCreateObject(Class,Title,Location,Setup,Option)

where Class is the WPS class of the object, in our case WPProgram since we will be executing a program. Title is simply the title that will appear in the window list when the program is running. Location is, you guessed it, <WP_NOWHERE> for our application. Setup is a setup string that lets us customize the object, and will be discussed below. Option is either Fail, Replace, or Update depending on what we want the SysCreateObject function to do if the object already exists. In our case, we will use Replace.

The setup string is where we can change DOS settings for our application. We start the setup string with:

EXENAME=c:\os2\mdos\command.com;

which is (probably) the path to the DOS executable. In the above case, we would simply be starting a DOS shell. Next we will add:

PROGTYPE=WINDOWEDVDM;

PROGTYPE can be either WINDOWEDVDM for a DOS window, or VDM for a full screen DOS session. And to set the startup directory, we use:

STARTUPDIR=c:\;

Finally we get to the purpose of all this work -- to set various DOS settings to certain values. Let's say we need to set DPMI_MEMORY_LIMIT to 16 and have IDLE_SENSITIVITY equal to 100. We just add the following to the setup string:

SET DPMI_MEMORY_LIMIT=16,IDLE_SENSITIVITY=100;

Note that different settings are separated by commas. Should you need to use a comma in your setup string, preface it with a carat (^) so that it's not interpreted as a field separator.

We're almost there. The last piece of information we need to supply is the view to be used when the object is created with:

OPEN=DEFAULT

We use DEFAULT for our DOS application. If we were creating a folder, we might use ICON, TREE, or DETAILS. Let's concatenate all of these into one string called Setup.

Setup='EXENAME=c:\os2\mdos\command.com;PROGTYPE=WINDOWEDVDM;STARTUPDIR=c:\;SET DPMI_MEMORY_LIMIT=16,IDLE_SENSITIVITY=100;OPEN=DEFAULT'

(Notice that the various parts are separated by semicolons.)

Now we are ready to make the call to SysCreateObject:

call SysCreateObject "WPProgram","Our Title","<WP_NOWHERE>",Setup,"Replace"

and our DOS application should run in a window with the settings we requested.

I've created a REXX program that you can modify to suit your purposes. It is commented, and you should have no problems following the flow of the program, and changing it to suit your needs. I have, of course, covered only a tiny fraction of the capabilities of the REXXUTIL library, and even only a small number of the capabilities of SysCreateObject.

A while back I put together an OS/2 help file (.inf) that had lots of information on various REXX libraries. You can get it at Hobbes as rxs960115.zip (ZIP, 109k) in the /os2/dev32/rexx directory. In it you will find fairly complete documentation of the setup string for SysCreateObject.


Dr. Dirk Terrell is an astronomer at the University of Florida specializing in interacting binary stars. His hobbies include cave diving, martial arts, painting and writing OS/2 software such as HTML Wizard.

[Index]  [® Previous] - [Feedback] - [Next ¯]

[Our Sponsor: Surf'nRexx - Build powerful Internet utilities using Surf'nRexx.]


This page is maintained by Falcon Networking. We welcome your suggestions.

Copyright © 1996 - Falcon Networking