[Access to Wang masthead]

Simulating paths on the VS

An alternative to putting common programs in the system library

From "VS Workshop",  Access to Wang, November 1992
  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  

One of the benefits of the VS operating environment is that it allows nearly any operating system feature to be constructed; one of its drawbacks is that so many now-common features are missing. As a frequent user of MS-DOS and UNIX, I have become accustomed to the path concept offered by these environments, and frustrated when confronted with an error when I leave off a volume name or mis-type a library name.

Of course, the VS operating system does have one form of a path: with LINK options properly set, the system will look first in the current library of execution and then in the system volume for an executable file. Many VS shops have resorted to placing common programs in the system library so that they can be accessed from many locations. This practice results in confusion when installing a new operating system version and loads up the system volume with extra programs executing.

While there are many possible solutions to these annoyances, let's explore a few ways to implement a path feature within the VS environment.

The RUNPATH VSAID

One easy way to provide a path alternative for your VS is to pick up a copy of the RUNPATH utility from the United States Society of Wang Users. RUNPATH provides a GETPARM to enter the file, library, and volume names of programs to be run and an option to search a path file for library and volume names. The user's INLIB and INVOL must be set to a valid library and volume at the time of the run, and this library must contain an 80-character file named PATH that holds the list of libraries to be examined. The RUNPATH screen also allows the user to create or edit the PATH list by pressing PF2. The Wang editor is used to enter the information. The path list may contain comments as well as library and volume names.

RUNPATH is useful in those instances where the program libraries are relatively stable and the PATH file can be located in the data library. Since the path file must be present in the same library are INLIB and INVOL are set - typically the application's data library location - it is often necessary to maintain multiple copies of the PATH file, making updates more difficult and error-prone. Still, RUNPATH makes it easier to run utility programs.

Creating your own RUNPATH

If you don't have a copy of RUNPATH or wish to build your own, a very serviceable replacement can be constructed using Procedure language. Such a procedure would have to perform the following functions:

1. Display a screen prompting for file, library, and volume names.

2. Store additional library and volume names for the path to be examined.

3. Attempt to find the program within the path. Figure 1 shows such a procedure. It accepts a file, library, and volume and checks for its existence; if not found, it searches the &PATH variable until a match is found. In addition, the contents of &PATH can be modified by pressing PF3 at the main screen.

This procedure uses the &LABEL built-in function to determine whether a step label exists, then runs it if it does. The PROMPT statements PFKEY = &KEY (2,2) appends the value of the PF key to the contents of &KEY (@), creating a string that can be used for a label. Pressing ENTER results in an &KEY value of @0, and the step label is found. Similar step labels exist for PF3 (@3) and PF16 (@16).

Next stop: GLOBAL variables

An interesting variation on the RUNPATH procedure listed below is to make the &PATH variable a GLOBAL variable, available to all procedures run below that link level. To do this, the DECLARE statement for &PATH must be changed to read as follows:


DECLARE &PATH GLOBAL STRING (70)
    INITIAL "@SYSTEM@" !! "SYSTEM" . . .

This statement should be inserted into a procedure run early in a terminal session - typically in the user's logon procedure. Once declared GLOBAL it should not be declared in other procedures, but these procedures can use the variable and its values as if it was declared locally. We'll cover more about GLOBAL variables in Procedure language next month.


Figure 1: Procedure RUNPATH


PROCEDURE RUNPATH - a simulation of PATH

DECLARE &RUNFIL   STRING (08)
DECLARE &RUNLIB   STRING (08)
DECLARE &RUNVOL   STRING (06)
DECLARE &POINTER  INTEGER
DECLARE &KEY      STRING (03) INITIAL "@  "
DECLARE &MSG      STRING (70)

DECLARE &PATH     STRING (70) [ room for five ]
    INITIAL "@SYSTEM@" !! "SYSTEM"
         !! "VSAIDS  " !! "SYSBAK"
         !! "USERAIDS" !! "SYSBK2"
         !! "DSBPROC " !! "SYSWRK"
         !! "DSBOBJ  " !! "SYSWRK"

RUNSCRN:               [ prompts for file to run ]
PROMPT    PFKEY = &KEY (2,2)
CENTER BRIGHT LINE "Run Program";;
CENTER "Program  FILE    =", UPPER &RUNFIL;
CENTER "         LIBRARY =", UPPER &RUNLIB;
CENTER "         VOLUME  =", UPPER &RUNVOL, " ";;
CENTER "Press PF3  to edit path names";
CENTER "Press PF16 to exit           ";;
CENTER BRIGHT &MSG(1,*);;

IF &LABEL (&KEY) CALL &KEY [ check for step label ]
GOTO RUNSCRN

* ENTER pressed at RUNSCRN ************************
@0:
IF EXISTS FILE &RUNFIL IN &RUNLIB ON &RUNVOL
   GOTO RUNPROG

ASSIGN &POINTER = 0
ASSIGN &MSG = " "

CHKPATH:   [ check entries in &PATH for match ]
ASSIGN &POINTER = &POINTER + 1
IF &POINTER > 5   GOTO NOTFOUND

IF NOT EXISTS FILE &RUNFIL          [ file ]
     IN &PATH ((&POINTER*14)-13,8)  [ library ]
     ON &PATH ((&POINTER*14)-5,6)   [ volume ]
GOTO CHKPATH

ASSIGN &RUNLIB = &PATH ((&POINTER*14)-13,8)
ASSIGN &RUNVOL = &PATH ((&POINTER*14)-5,6)
GOTO RUNPROG

NOTFOUND:  [ build error message ]
ASSIGN &MSG = "Program name not found on path"
END

RUNPROG:   [ run program ]
RUN &RUNFIL IN &RUNLIB ON &RUNVOL
CANCEL EXIT IS CANCRUN

ASSIGN &MSG = "Program " !! &RUNFIL (1,*)
           !! " completed"
END

CANCRUN:   [ build cancel message ]
ASSIGN &MSG = "Program " !! &RUNFIL (1,*)
           !! " cancelled"
END

* PF3 pressed at RUNSCRN **************************
@3:
PROMPT
CENTER BRIGHT LINE "Edit Path Names";;
CENTER "          ", LINE  "LIBRARY ",
       "  ",         LINE  "VOLUME";
CENTER "LIBRARY 1:", UPPER &PATH (1,8),
       "  ",         UPPER &PATH (9,6);
CENTER "LIBRARY 2:", UPPER &PATH (15,8),
       "  ",         UPPER &PATH (23,6);
CENTER "LIBRARY 3:", UPPER &PATH (29,8),
       "  ",         UPPER &PATH (37,6);
CENTER "LIBRARY 4:", UPPER &PATH (43,8),
       "  ",         UPPER &PATH (51,6);
CENTER "LIBRARY 5:", UPPER &PATH (57,8),
       "  ",         UPPER &PATH (65,6);;
CENTER "Press ENTER to continue"

END

* PF16 pressed at RUNSCRN *************************
@16: RETURN   [ end procedure ]

  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  


Copyright © 1992 Dennis S. Barnes
Reprints of this article are permitted without notification if the source of the information is clearly identified