The Esstu Pack

Index

S2Util

Another REXX callable library written in Pascal, S2Util is a repository of general functions that I thought would be handy. So far there aren't many functions exported, but I hope to increase their number.

The functions are:

S2WordSplit
Parse a string and split it into words on blank spaces, but counting quoted strings as single words. Words are put into elements of a REXX array-like stem (STEM.0 has the number of words, and STEM.1-STEM.n have the words).
S2ParseArgs
Parse an argument string. As well as parsing words and noticing quotes, arguments are preceded by a dash or slash, and consist of everything up to the next word with a dash or slash. The "value" of the argument is anything after a space, colon, or equals sign. Arguments, as well as being listed in the array, are hashed into the same stem as STEM.arg=argvalue (eg for the argument /FOO=BAR, STEM.FOO will have the value BAR). Note that if a nonzero numeric argument is passed (eg /1=2), then the "value" will be set (eg STEM.1=2), but if the argument 0 is passed (eg /0=asd), the "count" will override. STEM.0 will always hold the number of arguments.
S2Version
New in v2.0, this function (which really should have been there from the start) returns a string with the version number, a blank space, and then my contact details (name, email address, web site url). If this function doesn't exist, you've got an old version which has only WordSplit and ParseArgs.
S2GetHAB
New in v2.0, this function allows a Presentation Manager program to find out the Anchor Block Handle (HAB) when given a Window Handle (HWND; despite the potentially misleading name, all PM objects have HWNDs). A HAB can be used with S2GetResStr and also clipboard functions, ShutdownSystem, and similar, although S2GetResStr is the only one available now.
S2GetResStr
Get a string from a resource. Pass a HAB, a HMODULE (module handle; 0 to access own EXE), and a numeric ID (as specified in the .RC file), and the string is returned. Maximum length 255 characters - not sure how to overcome this.
S2MakeClipboardViewer
Pass this function a HWND and it makes that object into a Clipboard Viewer. This means, simply, that OS/2 will notify that object every time the clipboard is changed. See below for example VX-REXX code to use this.

A sample program, S2UTIL.CMD, has been included to demonstrate the use of the functions. It parses a string into words, parses a predefined argument string, and parses its own arguments. Test.EXE, another sample, has been included to demonstrate the PM functions. Run it, copy some text to the clipboard (from another program), and Test.EXE will give a short beep, show the new text in its window, and update the window's title to reflect the number of times the clipboard has changed since the program was started. To test S2GetResStr, click the button. Resource string 1 will be obtained from the executable and displayed. If you have the Resource Compiler, you should be able to change what String 1 says.

The three Presentation Manager routines (S2GetHAB, S2GetResStr, S2MakeClipboardViewer) should work in any PM REXX environment, including PMREXX, VX-REXX, VisPro REXX, GPF REXX, and any other PM program which uses REXX as a scripting language (eg PMMail, DBExpert, or DeScribe). However I have only tested them with VX-REXX, because that's where I do all my PM programming. Mostly I wanted the Clipboard Viewer routine; GetHAB was a byproduct of the experiments which led to it, and GetResStr was added as an excuse to keep GetHAB.

Full details on how to use the S2Util functions in VX-REXX can be found in S2VX.HTML. Information on other languages I don't yet have, but I may get it sometime. If anyone uses these routines in some other environment and wants to get a piece here, I'll consider adding another page or two.

File: S2UTIL.ZIP
Requires: OS/2
Installation: Unzip into directory on LIBPATH.
Operation: Call from REXX program.
De-installation: Delete.
Distribution: Open Source.