[Access to Wang masthead]

Routine Procedure

Exploring Wang subroutines with Procedure

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

Prior columns have concentrated on information for experienced VS technical users. This time, however, I would like to cover some items of interest to beginning programmers or technical users new to the VS: the use of Wang-supplied standard subroutines (referred to as VSSUBS, ISWUSUBS, or USERSUBS) for a variety of programming tasks. These routines - now supplied with operating systems - have been much of the foundation for applications programming since the dawn of the VS in the late seventies.

History

The origins of the current VSSUBS collection can be traced back to the early days of the VS, when many Wang employees worked hard to make the VS a machine of choice for developers. Most USERSUBS - as they were known at that time - were versions of assembler macros that were written to allow their use in high-level languages.

The first distribution for the USERSUBS was through user groups and local Wang offices. Many support technicians loaded them onto all systems they serviced, or users brought a diskette to a user group meeting for a copy of the latest versions. Wang did not officially support this activity, though they did publish the VS USERSUBS Manual in 1982 and updated documentation filtered out of Wang employees. The situation was analogous to the USERAIDS collection: items were written by Wang personnel but not officially acknowledged or supported by Wang.

Later, the International Society of Wang Users (ISWU) took control of the distribution efforts. Some of the subroutines received better documentation or improved features, but most did not change.

Finally, Wang accepted support of the most important subroutines and distributed them with operating systems, beginning with the 7.10 series. Recent operating system release has seen the number of supported subroutines grow to the current count of about 45. The VSSUBS Reference (pub. # 715-0599) was published to document these supported versions.

Why subroutines?

Subroutine libraries provide easy, standardized access to functions without the need to recreate them in each program. Many times the features delve into the heart of the system, offering functions beyond the reach of the application programmer operating in a high-level language.

While subroutines often provide additional capabilities, many are already available through Wang's Procedure language. Common EXTRACT items can be had with Procedure keywords, as with most MOUNT and RENAME options. Naturally, high-level languages still need subroutines to perform these operations.

Wang subroutine features

Some important points regarding Wang subroutines include:

1. Use from any language: With the exception of early versions of the RPGII compiler (a situation since rectified), all Wang subroutines can be used in any VS language directly. This means that the power available to assembler programmers was available to all. At that time this was introduced it was unusual in the computer world.

2. Link with STATIC or DYNAMIC access: Subroutines can be inserted directly into the final object code (a STATIC link) or called interactively during run time.

3. Can be called from Procedure: The availability of these subroutines within a procedure file allows greater features and control. As we will see below, it also provides an easy means of learning the effects of a subroutine without a large amount of programming.

4. Little changed: Even though VS operating systems have evolved far beyond their first capabilities, the most important subroutines show little or no change. This has allowed application programs to remain operational far beyond the normal software life cycle.

To illustrate, I have selected a few subroutines whose powers have been largely overlooked. These subroutines are DATE and DAY, MOUNT and DISMOUNT, and UNITRES. I will not attempt to present all information necessary to fully use the subroutines; consult the VSSUBS Reference for this information.

DAY and DATE in job control

The DATE subroutine has been featured in programming examples in many Wang-oriented columns, including several of mine. It offers several options, ranging from date conversions to computation of differences in time and formatted report headers. The DAY subroutine is used less; it returns the day of the week for a given date.

The addition of the &DATE function in Procedure language removed the need to use DATE for this function. There as still times when procedure control can be augmented through its use. For example, a procedure to control incremental backups could use the difference in days from the current date to schedule the next appropriate full backup. Similarly, the DAY subroutine can be used to trigger day-specific processes. Consider this example to run a task on Sundays only:


PROCEDURE DAYTEST - tests the DAY subroutine

DECLARE &DATEIN STRING (06)
DECLARE &DAYOUT INTEGER

ASSIGN  &DATEIN = &DATE         [ MMDDYY format ]

ASSIGN &DATEIN  = &DATEIN (5,2) [ Convert to YYMMDD ]
               !! &DATEIN (1,4) [ format            ]

RUN DAY IN VSSUBS ON SYSVOL USING &DATEIN, &DAYOUT

IF &DAYOUT = 1                  [ Sunday  ]
    CALL sunday_programs

Using MOUNT and DISMOUNT for disk control

While the MOUNT and DISMOUNT subroutines appear to offer little more than program control for functions on the Operator's Console, look more closely. Both will perform the logical mount and dismount tasks with specific control of label type, progress screen displays to the user, access restrictions, system file usage, label processing, and disk addressing mode.

The following procedure illustrates how you would use the MOUNT subroutine to logically mount a tape volume that is already physically mounted:


PROCEDURE MOUNTNOW - MOUNTs a tape already on the drive

DECLARE &RCODE INTEGER

RUN MOUNT IN VSSUBS ON SYSVOL
    USING  10,             [ Device number  ]
           "TAPE1A",       [ Name           ]
           0,              [ Vol set ID     ]
           "I",            [ IBM label      ]
           " ",            [ mount usage    ]
           " ",            [ drive type     ]
           0,              [ System use     ]
           " ",            [ Bypass option  ]
           "N",            [ Message option ]
           " ",            [ Display option ]
           " ",            [ Address        ]
           &RCODE          [ Return code    ]

Another use might be to change the use of system files on a given disk during operations. For example, a similar procedure could be used to shut off a given volume's WORK, PAGING, SPOOL, or SECURE system usage options without dismounting the volume. More radical uses might include non-standard disk I/O, such as interpreting disks formatted to PC or other foreign standards.

Take a number

Sometimes it is desirable to reserve a given device - such as a printer - for exclusive program use. In many cases this is accomplished by using the RELEASE option from the Operator's Console. UNITRES performs this function under program control, and can be incorporated into check printing programs and other sensitive operations.

This example in procedure language reserves a printer until the check printing process is successfully completed:


PROCEDURE CHECKOUT - demonstrates UNITRES

RUN UNITRES IN VSSUBS ON SYSVOL
    USING  "D+",           [ Reserve device ]
           &DEVNUMB,       [ Device number  ]
           &RCODE          [ Return code    ]

R: RUN checkprt

IF R <> 0      RETURN

RUN UNITRES IN VSSUBS ON SYSVOL
    USING  "D-",           [ Release device ]
           &DEVNUMB,       [ Device number  ]
           &RCODE          [ Return code    ]

RETURN

Further research

Many other interesting and helpful subroutine applications exists, including obscure EXTRACT calls for environmental data, hex and binary conversions, and string processing functions. What are your ideas? Pull down that VSSUBS manual and get cracking.


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


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