More on using Glossary for keystroke automation
From "VS Workshop", Access to Wang, January 1989
|[ Prior Article ] [ Return to the Catalog of articles ] [ Next Article ]|
In last month's column, I promised to supply more specifics on the use of Glossary programs to automate operations. Hopefully, those of you with little prior experience in Glossary programming will have worked through some examples, perhaps even using the Append option offered by the personality editor (WSPERSON; a.k.a. PERSON) to generate Glossary source. If you have performed this process you are ahead of the game, since that is the way I usually create individual modules for master Glossary programs.
The sample application I present here is necessarily limited in scope. It is quite possible to extend error-checking and fault tolerance far beyond what has been accorded here, but space limitations and relevance to overall needs dictate a simpler approach.
The example Glossary application presented here shows a simple, one-file automation scheme based on the following specifications:
The master procedure (ROBOT; see Figure 1) is run on a workstation every evening. It uses the PAUSE subroutine to wait until 11:30 p.m. to begin execution.
When the time is right, the procedure uses WSRSTR (a.k.a. MWSRSTR) to load a Multi-Station personality file into the workstation (see MON, Figure 2). This personality includes an Auto-Start procedure that logs onto the system in window 2 and runs several reports. The actual reports to be run is determined by the day of the week and the corresponding personality file; e.g., day '2' of the week corresponds to 'Monday', or MON.
The glossary source for each program to be run is retained in small source files and copied into the master Glossary when it is compiled (the %include function; see sample source RPT156, Figure 3). This allows modular use of the Glossary source and less likelihood of unintended differences in each day's processing.
At the conclusion of each routine, the process is examined for errors; if present, a screen dump is taken to capture the error information for later analysis.
At the conclusion of the process, the glossary logs off the second workstation screen and returns control to the first window. The ROBOT procedure then ends.
Initiating Multi-Station Glossaries is a process that is difficult to understand until seen in action. The Auto-Start procedure mentioned above refers to a Glossary procedure that automatically executes every time the personality file is loaded into the workstation. Interestingly, this special procedure acts as a Global Glossary; that is, it executes in all windows simultaneously. This is the reason that there is logic to check the screen number before proceeding.
The WSRSTR (or MWSRSTR) program is used to load the personality file. This differs from typical use in logon procedures and other interactive tasks, where the WSLOAD (or MWSLOAD) procedure is often used instead. The difference? WSLOAD extracts the user's ID and attempts to find a file by that name in a default library; if found, the file is loaded and the procedure ends. WSRSTR, on the other hand, allows you to load any Multi-Station file into the workstation regardless of its location and name.
The ROBOT example shown here uses a naming convention of the days of the week. In this manner, the same procedure can be used to run Glossaries every day of the week. Naturally, this simplistic approach would not work well when the data to be entered or programs run was subject to frequent change; in those instances, more sophisticated methods might be necessary. (More on this point below.)
One method of creating Glossaries is to build individual Glossary fragments (such as RPT156) by running the process to be automated manually and recording the keystrokes with Glossary-by-Example for later use with the Append function in the personality editor. The resulting code could then be edited and saved as individual files to be assembled during the compiler process.
Using the Glossary-by-Example approach greatly simplifies the editing process and usually produces more accurate source code. Since the personality editor generates the keywords, you only have to add any desired error checking and create the new source file. Pay particular attention to the screen location and actual text information presented during both error conditions and successful operation, as these are some of the only clues you have for error detection and logging. (A file of screen print files is very helpful in creating and maintaining Glossary programs where on-screen information is used for program control.)
Access to the Append function mandates use of the WSPERSON utility for Glossary editing, since this important function is only found there. Using WSPERSON also allows you to see the size in percent of the compiled Glossary code, so you can avoid overflowing the 2048-byte boundary allowed for Glossary programs.
Other topics to be considered include possible workstation security issues, space limitations, and further discussion of error handling. Since every situation is different, I will present only theory here.
A real danger of using Glossary to automate workstation operations is that some person or event will interrupt the process and cause it to abort. Worse, the use of Glossary offers little opportunity to log these problems for later analysis. The Glossary source pictured here uses screen dumps to log events, but this is predicated on the Glossary program retaining control of the workstation. As mentioned above, Glossaries can be irreversibly cancelled through use of RESET or HELP, resulting in the loss of all stored keystrokes.
Keyboard interruptions would be less likely if the type-ahead workstation feature was disabled. Another method of avoiding these interruptions might be to redefine the keyboard without any key functions, so no keys would work. (Remember that the key does not have to be present on the keyboard to be used by a Glossary.) Logging operations might be conducted via the TRACE function, invoked within the controlling procedure.
It is also likely that your application will require dynamic data entry for each run. For example, you may need to enter a date range for each report - data that changes with every run. A possible solution here lies in the use of the "pick up" and "put down" key functions, with the dynamic information displayed in a specific position on the workstation for Glossary access. Another method is to use Procedure Global variables, in which the contents of the variable remain in that task's memory and can be accessed by all other procedures run within.
I hope that the preceding discussion stimulates some of your thoughts for advanced use of Glossary programs. It should be obvious by now that this is a subject rich with potential. By all means, let me hear about some of your attempts at Glossary programming for all purposes.
Next month I'll sketch out an alternative text-processing environment that spans VS and PC word processing approaches, using local and host printers, storage, and processing resources.
Figure 1: Master Procedure to Load Multi-Station Files
PROCEDURE ROBOT - starts selected Multi-station tasks - * Literals follow DECLARE &JOBLIB STRING (08) INITIAL "WSPER " DECLARE &JOBTIM STRING (04) INITIAL "2330" [11:30 pm] * End literals DECLARE &JOBFIL STRING (08) DECLARE &SYSVOL STRING (06) DECLARE &HHMM STRING (04) DECLARE &MMDDYY STRING (06) DECLARE &YYMMDD STRING (06) DECLARE &DATINDEX INTEGER DECLARE &DATNAMES STRING (21) INITIAL "SUNMONTUEWEDTHUFRISAT" EXTRACT &SYSVOL = SYSVOL ASSIGN &MMDDYY = &DATE ASSIGN &YYMMDD = &MMDDYY(5,2) !! &MMDDYY(1,4) RUN DAY IN USERSUBS ON &SYSVOL USING &YYMMDD, &DATINDEX IF &DATINDEX < 1 OR &DATINDEX > 7 RETURN CODE = 999 [ Exit here ] ASSIGN &JOBFIL = &DATNAMES((&DATINDEX * 3) - 2, 3) MESSAGE CENTER "Batch job ", &JOBFIL(1,*), " waiting to begin--"; CENTER "Please do not touch!" * Loop to check times LOOP: RUN PAUSE IN USERSUBS ON &SYSVOL USING +6000 [ pause 1 minute ] ASSIGN &HHMM = &TIME IF &HHMM < &JOBTIM GOTO LOOP MESSAGE CENTER "Job ", &JOBFIL(1,*), " executing--"; CENTER "Please do not touch." RUN WSRSTR ENTER INPUT FILE = &JOBFIL, LIBRARY = &JOBLIB, VOLUME = &SYSVOL RETURN
Figure 2: Auto-Start Glossary for Daily Reporting
/***************************************************** Glossary MON - runs Monday reports and backup Last update: 08/01/88 DSB *****************************************************/ /************** Print Screen procedure ***************/ printscreen: procedure; call playout ('(-help!-)'); call waitforunlock; call playout ('(-pf-14-)'); call waitforunlock; call playout ('(-help!-)'); call waitforunlock; call playout ('(-pf-1-)'); end printscreen; /************ General Control Procedures *************/ %noprint /* Suppress printing of password */ logon: procedure; if substr(screen(1),41,5) = "Logon" then do; call playout('(-help!-)'); if window = 2 then do; call playout ("OP" !! char(window)); end; call playout ("password(-enter-)"); end; end logon; %print /* Resume printing */ logoff: do while (substr(screen(4),2,11) ^= "Workstation"); call playout ('(-pf-16-)'); call waitforunlock; end; end logoff; autologon: procedure options (main); do while window ^= 2; call playout ('(-get-n-)'); call waitforunlock; /****************** Daily reports ********************/ %include RPT156 /* Trial Balance (daily version) */ %include RPT201 /* Sales & Marketing Report (daily) */ %include RPT579 /* Transaction Summary */ %include RPT807 /* BACKUP - G/L, A/P, Sales */ %include PST116 /* Post New Cash */ end; call logoff; /* Log off screen 2; return to 1 */ do while window ^= 1; call playout ('(-get-n-)'); call waitforunlock; end; end autologon;
Figure 3: %include File RPT156 for Main Glossary
/******** RPT156 - prints daily Trial Balance ********/ call playout ('(-pf-1)(-pf-4-)'); call waitforunlock; call playout ('(-tab-)d(-tab-)(-tab-)x(-enter-)'); call waitforunlock; if substr(screen(23),2,10) ^= "SUCCESSFUL" then do; call printscreen; end; call playout ('(-pf-16-)(-pf-16-)'); call waitforunlock; /******************* End of RPT156 *******************/
Copyright © 1989 Dennis S. Barnes
Reprints of this article are permitted without notification if the source of the information is clearly identified