Build It Your Way

Автор: Richard K. Goran

Дата: November, 1995

Источник: EDM/2

Creating Program Objects in REXX

More and more frequently OS/2 users asking how to setup program objects on their OS/2 Desktops, or in other folders, in order to launch Windows and DOS applications seamlessly. With seamless program objects, non-OS/2 applications have the look and feel of OS/2 objects until they are actually started. More importantly, setting each Windows or DOS program up as its own program object allows you to customize the settings for that particular program.

When considering the settings for the Virtual DOS Machine (VDM) two things should be taken onto consideration: 1) Any overall WIN-OS2 defaults you wish to establish for your own system; and 2) Any specific characteristics you wish to setup for a specific VDM. The Add Programs facility in Warp attempts to do this for you by creating folders which contain program objects for every DOS, Windows, and OS/2 application that it thinks it can identify on your system. If the Search for and Select Programs option is selected, network drives are also searched. Though this works to a point, it can lead to a very messy situation, particularly if you have a lot of Windows program that you may have installed on your system on a trial basis and then deleted them from your Windows Program Manager without deleting the actual files. A more practical approach might be to write a REXX program that will create these program objects yourself and include just the Windows programs that you are actively using.

The specific setup strings that either the original program provider recommended, or that IBM felt were best, for a particular application can be taken from the \os2\install\database.txt file on your system. This file lists the majority of Windows applications and, for the most part, they are valid. The structure of database.txt is also included in all Warp systems in the file \os2\install\dbtags.dat. You will recognize most of the values in database.txt since the majority of the lines for a given program correspond to the Settings values you can adjust by opening the Settings Notebook for any DOS or Windows program object.

A more practical approach would be to use your Windows Program Manager as the basis for creating these program objects. That way, only the programs that you have setup under Windows would have corresponding OS/2 program objects created. Taking it a step further, by creating a folder which is the equivalent of your Windows Program Manager, folders could be created that mirror your Windows program groups. Within each program group would be an OS/2 program object corresponding to the Windows or DOS program within the group folder. All of this could be done manually using drag and drop from the Folder and Program templates which are located in the Templates folders which, in turn, is in the OS/2 System folder created on your Desktop when you install OS/2. Needless to say, that would be a very laborious task and would have to be repeated any time it is necessary to reinstall OS/2.

The same results could be achieved with a REXX program using the SysCreateObject() function in REXXUTIL. This is the technique used by the install portion of many of the OS/2 applications available today. [#Listing 1 Listing 1] is an example of creating a folder named Program Manager Desktop Equivalent on the Desktop. (The sequence numbers which appear at the end of each REXX line are solely for convenient reference within this article.) Within this folder we will create folders which will mirror their Windows Program Manager group counterparts. The techniques used here are applicable to OS/2 version 2.1 as well as Warp with the exception of specifying that the contents of the folders are to be sorted. The sort capability did not become generally available until Warp.

Every object you create should have an object ID since, without an ID, only file system objects can be referenced after the object is created. The definition of an object ID is any string of one or more characters preceded by a less than sign (<) and followed by a greater than sign (>). Each object ID within the system must be unique. [#Listing 1 Listing 1] uses "" as the object ID for the parent folder we are going to create (line 11). At first glance, it might appear that the title given to this folder is the same as the object ID without the leading and trailing characters. Not so. While the alphabetic characters are the same, the title has a caret (^) between the second and third words. This will result in the folder's title being split into two lines with the caret indicating where the line break is to occur.

Each object we create must have a Workplace Shell class associated with it. Only two classes are required here - WPFolder and WPProgram. Each object will also be assigned a title, specify the location where the object is to be created, and have one or more setup strings associated with it. The setup strings are made up of a key word and its related value. While many of the key word / value pairs that exist for WPS objects are documented in the online .inf files that come with OS/2, the only complete source for these setup string parameters is the [../rrsh-4/welcome.htm REXX Reference Summary Handbook].

The ALWAYSSORT= string (line 32) did not become generally available until Warp. Previously, it could only be used along with DeskMan/2. It results in the objects within the folder always being displayed in order by the object's title. The example in Listing 1 also provides the flexibility of assigning either FLOWED or NONGRID to a variable (line 19) so that a consistent format will be applied to each folder's icon view.

[#Listing 2 Listing 2] contains the instructions and setup string parameters for creating a folder that is equivalent to the Windows Accessories group. It is similar to the Program Manger Desktop Equivalent folder except that its location is the Program Manger Desktop Equivalent (line 10) indicated by using the object ID we assigned to the Program Manager Desktop Equivalent folder. Another difference is the use of the ICONRESOURCE= (line 17) and ICONNRESOURCE= (line 18) setup strings. Both of these setup strings specify the use of standard system icons imbedded within the pmwp.dll file. The first indicates the icon that will be displayed when the folder is closed and the second defines the icon that will be displayed for the folder when it is opened. Both parameters are optional with the folder having the default yellow file folder icon associated with it if no alternative is specified. Custom icons could also be specified with the ICONFILE= and ICONNFILE= parameters pointing to the desired icon files.

[#Listing 3 Listing 3">Listing 3] shows the REXX code that can be used to create two of the WPS program objects found in the Accessories group. Like the folder objects, program objects have setup string parameters that define the properties of the object. Program objects created for DOS and Windows programs also allow you to specify the characteristics of the VDM that will contain the program when it is launched. Each of these VDM parameters begins with SET and is followed by a key word / value pair. Any values specified for the program object override the default WIN-OS2 setup values and any VDM values specified in the OS/2 config.sys file.

Column space limits the number of program objects I have shown. A more complete listing, as well as machine readable versions of the listings included in this article, can be downloaded via anonymous ftp from, or via the World Wide Web at (Альтернативная ссылка). The file[../mkwinos2/mkwinrun.txt mkwinrun.txt] contains a complete REXX program showing multiple program group folders and program objects. There is also a commercial program product, [../mkwinos2/welcome.htm MKWINOS2]', that creates all of the group folders and their respective program objects for Windows Program Manager. MKWINOS2' may be used free of charge to build the Program Manager Desktop Equivalent folder and all of the other group folders for your system. It will also create the program objects for all of the programs contained in the Accessories, , Main, and Startup groups. It is not necessary to obtain a key to unlock the program if you want to create your own program objects for the remaining program objects on your system. The file can be downloaded via anonymous ftp or [../mkwinos2/ via the World Wide Web] (Альтернативная ссылка).

Listing 1

 /*----------------------------------------------------------*\ /*01*/
 |  9511LS01.CMD - Create Program Manager Desktop Equivalent  | /*02*/
 \*----------------------------------------------------------*/ /*03*/
 /* Assure that REXXUTIL is loaded */                           /*04*/
 call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'      /*05*/
 call SysLoadFuncs                                              /*06*/
 /*-------------------------------*\                            /*08*/
 |  Initialization and Setup code  |                            /*09*/
 \*-------------------------------*/                            /*10*/
 GBL.desktop_object_id = "" /*11*/
 GBL.desktop_title     = "Program Manager^Desktop Equivalent"   /*12*/
 GBL.font              = "8.Helv"                               /*13*/
 /*---------------------------------------*\                    /*15*/
 |  The following value(s) can be changed  |                    /*16*/
 |  to suit your personal taste.           |                    /*17*/
 \*---------------------------------------*/                    /*18*/
 GBL.icon_view   = "FLOWED" /* can be set to FLOWED | NONGRID *//*19*/
 GBL.sort_option = "YES"    /* can be set to YES    | NO      *//*20*/
 /*-------------------------------*\                            /*22*/
 |  Build Program Manager Desktop  |                            /*23*/
 |  Equivalent on OS/2 Desktop     |                            /*24*/
 \*-------------------------------*/                            /*25*/
 say COPIES( " ", 3 ) || "Building" GBL.desktop_title           /*26*/
 folder_class    = "WPFolder"                                   /*27*/
 folder_title    = GBL.desktop_title                            /*28*/
 folder_location = ""                               /*29*/
 folder_option   = "UPDATE"                                     /*30*/
 folder_setup    =,                                             /*31*/
    "ALWAYSSORT="  || GBL.sort_option  || ";"        ||,        /*32*/
    "ICONFONT="    || GBL.font         || ";"        ||,        /*33*/
    "ICONVIEW="    || GBL.icon_view    || ",NORMAL;" ||,        /*34*/
    "OBJECTID=;"            /*35*/
 call SysCreateObject folder_class,,                            /*36*/
                      folder_title,,                            /*37*/
                      folder_location,,                         /*38*/
                      folder_setup,,                            /*39*/
                      folder_option                             /*40*/
 if RESULT <> 1 then                                            /*41*/
    do                                                          /*42*/
       say "   Unable to create " || folder_title               /*43*/
       say "      folder, program cancelled."                   /*44*/
       exit                                                     /*45*/
    end                                                         /*46*/

Listing 2

 /*-------------------------------------------*\          /*01*/
 |  9511LS02.CMD - Create Group Folder Object  |          /*02*/
 \*-------------------------------------------*/          /*03*/
 /*-------------------------------------*\                /*04*/
 |  Build Group folder for: Accessories  |                /*05*/
 \*-------------------------------------*/                /*06*/
 say COPIES( " ", 6 ) || "Building Accessories folder."   /*07*/
 folder_class    = "WPFolder"                             /*08*/
 folder_title    = "Accessories"                          /*09*/
 folder_location = "" /*10*/
 folder_option   = "UPDATE"                               /*11*/
 folder_setup    =,                                       /*12*/
    "DETAILSFONT="  || GBL.font || ";"             ||,    /*13*/
    "TREEVIEWFONT=" || GBL.font || ";"             ||,    /*14*/
    "ICONFONT="     || GBL.font || ";"             ||,    /*15*/
    "ICONVIEW="     || GBL.icon_view || ",NORMAL;" ||,    /*16*/
    "ICONRESOURCE=72,PMWP;"                        ||,    /*17*/
    "ICONNRESOURCE=35,PMWP;"                       ||,    /*18*/
    "ALWAYSSORT="  || GBL.sort_option  || ";"      ||,    /*19*/
    "OBJECTID=;"                       /*20*/
 call SysCreateObject folder_class,,                      /*21*/
                      folder_title,,                      /*22*/
                      folder_location,,                   /*23*/
                      folder_setup,,                      /*24*/
                      folder_option                       /*25*/
 if RESULT <> 1 then                                      /*26*/
    do                                                    /*27*/
       say "   Unable to create " || folder_title ||,     /*28*/
           "group folder."                                /*29*/
       exit                                               /*30*/
    end                                                   /*31*/

Listing 3

 /*---------------------------------------------------*\  /*01*/
 |  9511LS03.CMD - Create Accessories Program objects  |  /*02*/
 \*---------------------------------------------------*/  /*03*/
    /*-----------------------------------*\               /*04*/
    |  Build WPProgram object for: Write  |               /*05*/
    \*-----------------------------------*/               /*06*/
    program_class    = "WPProgram"                        /*07*/
    program_title    = "Write"                            /*08*/
    program_location = ""              /*09*/
    program_option   = "UPDATE"                           /*10*/
    program_setup    =,                                   /*11*/
       "EXENAME=C:\WINDOWS\WRITE.EXE;"     ||,            /*12*/
       "STARTUPDIR=C:\WINDOWS;"            ||,            /*13*/
       "SET DPMI_MEMORY_LIMIT=64;"         ||,            /*14*/
       "SET IDLE_SECONDS=3;"               ||,            /*15*/
       "SET KBD_ALTHOME_BYPASS=1;"         ||,            /*16*/
       "SET VIDEO_SWITCH_NOTIFICATION=1;"  ||,            /*17*/
       "SET WIN_ATM=1;"                    ||,            /*18*/
       "SET WIN_CLIPBOARD=1;"              ||,            /*19*/
       "SET WIN_DDE=1;"                    ||,            /*20*/
       "SET XMS_MEMORY_LIMIT=16384;"       ||,            /*21*/
       "OBJECTID=;"                                /*22*/
    call SysCreateObject program_class,,                  /*23*/
                         program_title,,                  /*24*/
                         program_location,,               /*25*/
                         program_setup,,                  /*26*/
                         program_option                   /*27*/
    if RESULT <> 1 then                                   /*28*/
       do                                                 /*29*/
          say "   Unable to create " || program_title ||, /*30*/
              " program object,"                          /*31*/
          exit                                            /*32*/
       end                                                /*33*/
    /*------------------------------------------*\        /*35*/
    |  Build WPProgram object for: Media Player  |        /*36*/
    \*------------------------------------------*/        /*37*/
    program_class    = "WPProgram"                        /*38*/
    program_title    = "Media Player"                     /*39*/
    program_location = ""              /*40*/
    program_option   = "UPDATE"                           /*41*/
    program_setup    =,                                   /*42*/
       "EXENAME=C:\WINDOWS\MPLAYER.EXE;"   ||,            /*43*/
       "STARTUPDIR=C:\WINDOWS;"            ||,            /*44*/
       "SET DPMI_MEMORY_LIMIT=64;"         ||,            /*45*/
       "SET EMS_MEMORY_LIMIT=0;"           ||,            /*46*/
       "SET IDLE_SECONDS=3;"               ||,            /*47*/
       "SET INT_DURING_IO=1;"              ||,            /*48*/
       "SET KBD_ALTHOME_BYPASS=1;"         ||,            /*49*/
       "SET MOUSE_EXCLUSIVE_ACCESS=0;"     ||,            /*50*/
       "SET VIDEO_8514A_XGA_IOTRAP=0;"     ||,            /*51*/
       "SET VIDEO_RETRACE_EMULATION=1;"    ||,            /*52*/
       "SET VIDEO_SWITCH_NOTIFICATION=1;"  ||,            /*53*/
       "SET WIN_ATM=1;"                    ||,            /*54*/
       "SET WIN_CLIPBOARD=1;"              ||,            /*55*/
       "SET WIN_DDE=1;"                    ||,            /*56*/
       "SET XMS_MEMORY_LIMIT=16384;"       ||,            /*57*/
       "OBJECTID=;"                         /*58*/
    call SysCreateObject program_class,,                  /*59*/
                         program_title,,                  /*60*/
                         program_location,,               /*61*/
                         program_setup,,                  /*62*/
                         program_option                   /*63*/
    if RESULT <> 1 then                                   /*64*/
       do                                                 /*65*/
          say "   Unable to create " || program_title ||, /*66*/
              " program object,"                          /*67*/
          exit                                            /*68*/
       end                                                /*69*/