Jump to content

REXX Tips & Tricks:Change the WPS with REXX

From EDM2

This section contains hints for using REXX to change the WPS.

WPS class hierarchy

This section contains the class tree for WARP 3 and WARP 4.

To get a list of all registered classes on your system use the function SysQueryClassList().

To get a hierarchical list of the WPS classes registered on your system you can use the Search-Button of the LaunchPad (or the entry Find ... in the WPS context menu) as follows:

  • Open the Find dialog
  • Push the More ... button in the Find dialog to open the Find Criteria dialog
  • Push the Add button in the Find Criteria dialog to open the Add Criteria dialog
  • Select Object Class for the field Attribute in the Add Criteria dialog
  • Now you can scroll the hierarchical list of the registered classes in the list box Comparison value.

In der deutschen Version von WARP oeffnet mensch hierfuer den Suchen Dialog (ueber den Suchen Button der Klickstartleiste oder ueber den Eintrag Suchen im Kontextmenue der WPS. Dort klickt mensch den Button Weitere und in den daraufhin erscheinenden Dialog den Button Hinzufuegen In diesen Dialog nun setzt mensch das Feld Merkmal auf ObjektKlasse. Nun kann in der Listbox Vergleichswert die hierarchische Liste der registrierten WPS Klassen durch gescrollt werden.

WARP Version 3 Class hierarchy

WPS Class hierarchy for WARP Version 3 (see also the WPS Class hierarchy for WARP 4).


CLASS NAME CLASS DEFINITION FILE
SOMObject somobj.idl
SOMClass somcls.idl
SOMClassMgr somcm.idl
WPObject wpobject.idl
WPAbstract wpabs.idl
WPClock wpclock.idl
WPCountry wpctry.idl
WPDisk wpdisk.idl
WPKeyboard wpkeybd.idl.idl
WPLaunchPad wplnchpd.idl
WPMouse wpmouse.idl
WPSchemePalette wppalet.idl
WPColorPalette wpclrpal.idl
WPFontPalette wpfntpal.idl
WPSchemePalette wpscheme.idl
WPPower wppower.idl
WPPrinter wpprint.idl
WPRPrinter wprprint.idl
WPProgram wppgm.idl
WPShadow wpshadow.idl
WPNetLink wpnetlnk.idl
WPShredder wpshred.idl
WPSound wpsound.idl
WPSpecialNeeds wpspneed.idl
WPSpool wpspool.idl
WPSystem wpsystem.idl
WPWinConfig wincfg.idl
WPFileSystem wpfsys.idl
WPDataFile wpdataf.idl
WPBitmap wpbitmap.idl
WebExplorer_Url
WPIcon wpicon.idl
WPMet wpmet.idl
WPPif wppif.idl
WPPointer wpptr.idl
WPProgramFile wppgmf.idl
WPCommandFile wpcmdf.idl
WPFolder wpfolder.idl
WPDesktop wpdesk.idl
WPDrives wpdrives.idl
WPMinWinViewer wpmwv.idl
WPNetgrp wpnetgrp.idl
WPNetwork wpnetwrk.idl
WPRootFolder wprootf.idl
WPServer wpserver.idl
WPSharedDir wpshdir.idl
WPStartup wpstart.idl
WPTemplates wptemps.idl
WPTransient wptrans.idl
WPJob wpjob.idl
WPPdr wppdr.idl
WPPort wpport.idl
WPQdr wpqdr.idl

(except for the classes marked with *. These are no standard WPS classes.)

WARP Version 4 Class hierarchy

WPS Class hierarchy for WARP Version 4 (see also the WPS Class hierarchy for WARP 3).


CLASS NAME                         CLASS DEFINITION FILE
SOMObject                                     somobj.idl
  ÃÄÄÄSOMClass                                somcls.idl
  ÃÄÄÄSOMClassMgr                             somcm.idl
  ³    ÀÄWPClassManager                       wpclsmgr.idl
  ÀÄÄÄWPObject                                wpobject.idl
        ÚÄÄÄÄÄWPAbstract                      wpabs.idl
        ³     ÃÄÄ WPClock                     wpclkm.idl
        ³     ÃÄÄ WPCountry                   wpctry.idl
        ³     ÃÄÄ WPDisk                      wpdisk.idl
        ³     ÃÄÄ WPLaunchPad                 wplnchpd.idl
        ³     ³     ÀÄÄSmartCenter
        ³     ÃÄÄ WPKeyboard                  wpkeybd.idl
        ³     ÃÄÄ WPMouse                     wpmouse.idl
        ³     ÃÄÄ WPPalette                   wppalet.idl
        ³     ³     ÃÄÄ WPColorPalette        wpclrpal.idl
        ³     ³     ÃÄÄ WPFontPalette         wpfntpal.idl
        ³     ³     ÀÄÄ WPSchemePalette       wpscheme.idl
        ³     ÃÄÄ WPPower                     wppower.idl
        ³     ÃÄÄ WPPrinter                   wpprint.idl
        ³     ³     ÀÄÄ WPRPrinter            wprprint.idl
        ³     ÃÄÄ WPProgram                   wppgm.idl
        ³     ÃÄÄ WPShadow                    wpshadow.idl
        ³     ³     ÀÄÄ WPNetLink             wpnetlnk.idl
        ³     ÃÄÄ WPShredder                  wpshred.idl
        ³     ÃÄÄ WPSound                     wpsound.idl
        ³     ÃÄÄ WPSpecialNeeds              wpspneed.idl
        ³     ÃÄÄ WPSpool                     wpspool.idl
        ³     ÃÄÄ WPSystem                    wpsystem.idl
        ³     ÀÄÄ WPWinConfig                 wincfg.idl
        ÃÄÄ WPFileSystem                      wpfsys.idl
        ³     ÃÄÄ WPDataFile                  wpdataf.idl
        ³     ³     ÃÄÄ WPHtml                wphtml.idl
        ³     ³     ÃÄÄ WPIcon                wpicon.idl
        ³     ³     ÃÄÄ WPImageFile           wpimage.idl
        ³     ³     ³      ÀÄÄ WPBitmap       wpbitmap.idl
        ³     ³     ÃÄÄ WPMet                 wpmet.idl
        ³     ³     ÃÄÄ WPPif                 wppif.idl
        ³     ³     ÃÄÄ WPPointer             wpptr.idl
        ³     ³     ÃÄÄ WPProgramFile         wppgmf.idl
        ³     ³     ³       ÀÄÄ WPCommandFile wpcmdf.idl
        ³     ³     ÃÄÄ WPUrl                 wpurl.idl
        ³     ÃÄÄ WPFolder                    wpfolder.idl
        ³     ³     ÃÄÄ WPDesktop             wpdesk.idl
        ³     ³     ÃÄÄ WPDrives              wpdrives.idl
        ³     ³     ÃÄÄ WPHost                 wphost.idl
        ³     ³     ÃÄÄ WPHwManager           wphwmgr.idl
        ³     ³     ÃÄÄ WPMinWinViewer        wpmwv.idl
        ³     ³     ÃÄÄ WPNetgrp              wpnetgrp.idl
        ³     ³     ÃÄÄ WPNetwork             wpnetwrk.idl
        ³     ³     ÃÄÄ WPRootFolder          wprootf.idl
        ³     ³     ÃÄÄ WPServer              wpserver.idl
        ³     ³     ÃÄÄ WPSharedDir           wpshdir.idl
        ³     ³     ÃÄÄ WPStartup             wpstart.idl
        ³     ³     ÃÄÄ WPTemplates           wptemps.idl
        ³     ³     ÀÄÄ WPUrlFolder           wpurlfdr.idl
        ÀÄÄ WPTransient                       wptrans.idl
              ÚÄÄ WPJob                       wpjob.idl
              ÃÄÄ WPDevice                    wpdevice.idl
              ³     ÃÄÄ WPDevAudio            wpaudio.idl
              ³     ÃÄÄ WPDevBus              wpbus.idl
              ³     ÃÄÄ WPDevCDRom            wpcdrom.idl
              ³     ÃÄÄ WPDevCPU              wpcpu.idl
              ³     ÃÄÄ WPDevDiskette         wpdskett.idl
              ³     ÃÄÄ WPDevDisplay          wpdisply.idl
              ³     ÃÄÄ WPDevHarddrive        wphrddrv.idl
              ³     ÃÄÄ WPDevKeyboard         wpkeybdd.idl
              ³     ÃÄÄ WPDevMemory           wpmem.idl
              ³     ÃÄÄ WPDevMouse            wpmoused.idl
              ³     ÃÄÄ WPDevParallel         wpparal.idl
              ³     ÃÄÄ WPDevPeriph           wpperiph.idl
              ³     ÃÄÄ WPDevSerial           wpserial.idl
              ³     ÃÄÄ WPDevTape             wptape.idl
              ³     ÀÄÄ WPDevTimer            wptimer.idl
              ÃÄÄ WPPort                      wpport.idl
              ÃÄÄ WPPdr                       wppdr.idl
              ÀÄÄ WPQdr                       wpqdr.idl

Note: According to the REXX Reference Summary Handbook the class SmartCenter is a sub class of WPAbstract. I have not been able to verify this.


Extended Attributes used by the WPS

The Workplace Shell uses the following extended attributes:

Extended Attribute EA Type Description
ASSOCTABLE EAT_MVMT Enables an application to indicate the type, extension, and icon for the data file that it recognizes.
.CLASSINFO EAT_BINARY the class type of the object.
.CODEPAGE the code page for the file object
.COMMENTS EAT_MVMT misc. notes or reminders about the file object
.HISTORY EAT_MVMT the modification history for a file object (see Maintaine Multi value EAs in REXX for an example for using this EA)
.ICON EAT_ICON the icon that represents the file or folder object. This EA contains the physical data used to represent the folder object. (see also Extract the icon from the EAs)
.ICON1 EAT_ICON the animation icon for a folder. This EA contains the physical data used to represent the open folder object. (see also Extract the icon from the EAs)
.ICONPOS EAT_BINARY the icon positioning information for a folder (WARP 4 only!)
.KEYPHRASES EAT_MVMT text phrases for the file
.LONGNAME EAT_ASCII the long name of the file object (necessary for file system that do not support long names) (see Copy a file from HPFS to FAT and vice versa for an usage example)
.PREVCLASS EAT_BINARY "old class name when the user requests that an object, which is a descendent of WPDataFile, becomes another subclass of WPDataFile" (WARP 4 only!)
.SUBJECT EAT_ASCII a brief summary of the content or purpose of the file object
.TYPE EAT_MVMT the file type of the file object, such as plain text (TXT), bitmap (BMP), or executable (EXE).
.VERSION EAT_ASCII or EAT_BINARY the version of the file object


See the next section for the possible EA types.

Note: "Standard Extended Attributes (SEAs) have a dot (.) as a prefix. This identifies the extended attribute as a SEA. The leading dot is reserved, so applications should not define extended attributes that start with a dot. Also, extended attributes that start with the characters $, @, &, or + are reserved for system use."

Be aware that the information about the types of the Standard Extended Attributes in the Control Program Guide and Reference is not correct!

Extended Attribute Data Types

The first WORD of an EA specifies the type of the EA. The following EA types are defined (see Maintaining Multi-Value EAs in REXX for example REXX code to handle EAs):

Data Type Value
EAT_ASCII 'FFFD'x

Description: This EA contains ASCII text. The first WORD following the data type specifies the length of the data; the next bytes are the data.

Example: EAT_ASCII '0005'x 'Hello'


Data Type Value
EAT_BINARY 'FFFE'x

Description: This EA contains binary (non-text) data. The first WORD following the data type specifies the length of the data; the next bytes are the data.

Example: EAT_BINARY '0003'x '01'x '02'x '03'x

Data Type Value
EAT_BITMAP 'FFFB'x

Description: This EA contains bit map data. The first WORD following the data type specifies the length of the data; the next bytes are the data.

Example: EAT_BITMAP '0203'x bitmap_data

Data Type Value
EAT_METAFILE 'FFFA'x

Description: This EA contains metafile data. The first WORD following the data type specifies the length of the data; the next bytes are the data.

Example: EAT_METAFILE '0203'x metaFile_data


Data Type Value
EAT_ICON 'FFF9'x

Description: This EA contains icon data. The first WORD following the data type specifies the length of the data; the next bytes are the data.

Example: EAT_ICON '1BF8'x icon_data

Data Type Value
EAT_EA 'FFEE'x

Description: This EA contains the ASCII name of another EA that is associated with the file. The contents of that EA are to be included in the current EA. The first WORD following the data type specifies the length of the name of the other EA; the next bytes are the name of the EA to include.

Example: EAT_EA '0008'x AB.STUFF

Data Type Value
EAT_MVMT 'FFDF'x

Description: This EA contains multi-valued, multi-typed data -- two or more consecutive extended attribute values. Each value has an explicitly specified type. The first WORD following the data type specifies the codepage (0000 means default); the second WORD following the data type specifies the number of the following entries. The next bytes specify the EA values in the "normal" EA format (see the description for the other entries). Note that the Code page data is for use by the application; the operating system does not use it.

Example: EA_MVMT '0000'x '0003'x EAT_ASCII '0005'x Hello

EAT_EA '0008'x AB.STUFF

EAT_BINARY '0003'x '01'x '02'x '03'x

Data Type Value
EAT_MVST FFDE'x

Description: This EA contains multi-valued, single-typed data-two or more consecutive extended attribute values. All values have the same type. The first WORD following the data type specifies the codepage (0000 means default); the second WORD following the data type specifies the number of the following entries. The next word specifies the data type of the values and after that the data of the values follow.

Example: EAT_MVST 0000 0003 EAT_ASCII 0004 Mark

0005 Ellen

0003 Liz

Data Type Value
EAT_ASN1 'FFDD'x

Description: This EA contains ANS.1 field data; an ISO standard for describing multivalue data streams.

Data Type Value
'8000'x and up

Description: These values are reserved for the Operating System.


Data Type Value
'0000'x - '7FFF'x


Description: These values can be defined by the user. All user-defined data types should be length-preceded, meaning that a WORD indicating the length of the data (in bytes) precedes the data.

Source: Control Program Guide and Reference

Force the WPS to reRead the Extended Attributes

To force the WPS to reread the Extended Attributes (for example after changing the EA .LONGNAME) of a file you can use the following code (Source: Found in a public newsgroup):

/*   */
  CALL RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  CALL SysLoadFuncs

                    /* create a temporary file in the TEMP directory  */
  tempDir = value( 'TEMP',, 'OS2ENVIRONMENT' )
  tempFile = time('S')

  if right( tempDir,1 ) = '\' then
    tempFile = tempDir || tempFile
  else
    tempFile = tempDir || '\' || tempFile

                    /* now open the folder on the WPS                 */
  call SysSetObjectData tempDir, 'OPEN=DEFAULT;'

  say 'Creating a file named "' || tempFile || '" ...'

                    /* create a temporary file                        */
  '@ECHO. This is a test file ' '>'tempFile
  say ' ... done'

  say 'Press any key after the file is shown in the folder ...'
  '@pause >NUL'

                    /* new value for the EA .LONGNAME                 */
  NewLongName = 'This is a very looong Name' || '00'x

                    /* create a valid EA                              */
  typeinfo = 'FDFF'x || d2c(length(NewLongName)) || '00'x || NewLongName

  say 'Now changing the EA .LONGNAME of the file to'
  say ' "' || newLongName ||  '" ...'
  say '(This should change the title used in the WPS!)'

                   /* change the EA                                   */
  call SysPutEA tempFile, ".LONGNAME", typeinfo
  say ' ... done'
  say
  say 'Press any key to force the WPS to reRead the EAs'
  say '(and update the title in the folder) ...'
  '@pause >NUL'

                   /* force the WPS to reread the EAs                 */
  '@attrib -a ' tempFile '2>NUL 1>NUL'
  '@attrib +a ' tempFile '2>NUL 1>NUL'

  say 'Now the WPS should show the new title for the object.'

  say 'Press any key to delete the temporary file ...'
  '@pause >NUL'

                    /* delete the temporary file                      */
  '@DEL ' tempFile '2>NUL 1>NUL'
exit 0
 

Format of the RC files for MAKEINI

A detailed description of the format of the RC files used by MAKEINI is included in the book OS/2 2.11 Power Techniques. (see also Predefined Object IDs)

Note: see Get the default object settings for an example for parsing an RC file.

Note: In OS/2 WARP, the UPDATE and REPLACE flags in the setup strings of some of the entries in the INI.RC have no effect on the options in the object's pop-up menu of existing objects. To get around this limitation, use �SysSetObjectData to change the object properties (Source: APAR PJ18673).

Contents of the OS/2 INI files

OS/2 saves a big part of its configuration in the files OS2.INI and OS2SYS.INI. Therefore, many of the changes you might make to the WPS with REXX will involve changing some entries in these INI files.

The basic structure of OS/2 INI files is hierarchical, consisting of the following elements and order:


 Application
             Key
                 Value

Applications are the main entries. Each application must have at least one Key, and each Key must have a Value (Note that a lot of Values - but not all - include a trailing NULL byte ['00'x]). This byte may be needed for certain values to function properly. It should not be discarded when values are modified.)

To read or change INI file entries in REXX programs you can use the REXXUTIL function �SysIni. For example, to read the value of the key PDR_DIR of the application PM_INSTALL in the file OS2.INI you can use the REXX statement


  pdr_dir = SysIni( 'USER', 'PM_INSTALL', 'PDR_DIR' )
  if pdr_dir = 'ERROR:' then
     say 'Error reading the key from the INI file!'

To change the value of this key you can use


  newPDR_DIR = 'I:\OS2IMAGE' || '00'x
  thisRC = SysIni( 'USER', 'PM_INSTALL', 'PDR_DIR', newPDR_DIR )
  if thisRC = 'ERROR:' then
     say 'Error reading the key from the INI file!'

(BTW: The key used in the example above holds the name of the directory with the OS/2 image files (I:\OS2IMAGE) from which the system was installed. The value of this key is also the default value for the directory containing the OS/2 image if you do a Selective Install. The drive letter represents the drive that was used when the system was installed; therefore it can differ from one installation to another)

A detailed description of the contents of the OS/2 INI files (including many REXX samples to change the entries) is included in the book OS/2 2.11 Power Techniques. (Don't mind the version 2.11 in the title - the book is also useful for WARP 4).

Some useful entries are described in the next sections.

Note that, unless noted otherwise, all entries below have been tested only with OS/2 WARP Version 3.

You can use the program ConvIni.CMD to convert parts or all of an INI file into a REXX program to recreate the INI file entries.

Sample INI file entries

Following is a list of some useful entries in the OS/2 INI files. Warning:

Be aware that these entries are not documented by IBM! They may change in different releases of OS/2 without notice! (see Changing the Lockup page entries for an example)

Use this information with extreme care! Improper use could lead to unpredictable behavior of the system, possibly including problems booting and starting the WPS. Further Warning:

The names (!) of some keys in the INI files are language dependent! (see Font Size for text (VIO) windows for an example)!


OS2.INI

Country dependent information

File OS2.INI

Application PM_National

Key (various, see below)

Value

Description This application contains the country-dependent information

Created -

Deleted -

Possible keys for this application (copied from the file \OS2\INI.RC. ):


 "iCountry"      "1"   /* Country code (phone ID of country)         */
 "iDate"         "0"   /* Date mode (0:MDY, 1:DMY, 2:YMD)            */
 "iCurrency"     "0"   /* Currency mode 0: prefix, no sep            */
                       /*    1: suffix, no separation                */
                       /*    2: prefix, 1 CHAR separation            */
                       /*    3: suffix, 1 CHAR separation            */
 "iDigits"       "2"   /* Signif Decimal digits in Currency          */
 "iTime"         "0"   /* time mode (0=12 hours clock, 1=24)         */
 "iLzero"        "0"   /* Leading zeros (0: no, 1: yes)              */
 "s1159"         "AM"  /* Trailing string 0:00 to 11:59              */
 "s2359"         "PM"  /* Trailing string 12:00 to 23:59             */
 "sCurrency"     "$"   /* Currency Symbol string                     */
 "sThousand"     ","   /* Thousands separator string                 */
 "sDecimal"      "."   /* Decimal separator string                   */
 "sDate"         "-"   /* Date separator string                      */
 "sTime"         ":"   /* time separator string                      */
 "sList"         ","   /* List separator string.                     */
 "iMeasurement"  "1"   /* 1=English, 2=Metric, 3=Points, 4=Picaa     */