HP 3000 Manuals

Running the Demonstration Programs [ COBOL/HP-UX Operating Guide for the Series 700 and 800 ] MPE/iX 5.0 Documentation


COBOL/HP-UX Operating Guide for the Series 700 and 800

Running the Demonstration Programs 

To run the demonstration programs you must first of all install the COBOL
system software on your multi-user UNIX system following the instructions
given in your Read This First  card.

When you have done this, compile the programs mudemo.cbl, stockin.cbl,
stockout.cbl, stockioa.cbl and stockiom.cbl using the following command:

     cob -u mudemo.cbl stockin.cbl stockout.cbl
        stockioa.cbl stockiom.cbl

Move the resulting generated code modules mudemo.gnt, stockin.gnt,
stockout.gnt, stockioa.gnt and stockiom.gnt to an area where operators on
both terminals can access them.  You must also make sure that both
operators are accessing the same file.

To run the multi-user demonstration programs enter:

     cobrun mudemo

on both terminals.  Both screens display the initial screen as shown in
Figure 16-1 .

[]
Figure 16-1. Initial Screen When the initial screen is displayed, the operator must choose the access and lock mode by pressing the number associated with the required mode, followed by Enter. When the operator has chosen, the relevant subprogram is called by the main program mudemo, and another screen is displayed. This screen shows a "Stock Control System" with stock code, stock description, stock held and cost per unit. The bottom of the screen shows the open and lock modes, what the last operation was and whether it was successful, and the file status. Again, there is a choice of operations the operator may want to perform. Creating the File The first thing you must do to set up the multi-user environment is to create a data file that the two operators can share. One operator must create this file by selecting input choice 4 to open the file for output.
[]
Figure 16-2. Screen to Create a New Record When the screen shown in Figure 16-2 is displayed, this operator should enter data in the stock code, stock description, stock held and cost per unit fields using the Tab key to move to forwards from field to field. When this operator has entered data into these fields, this data can be written into the data file mustock.dat by writing the record. To do this, select option 1 (write record) and press Enter. We suggest that this operator writes five or six records in this way and then closes the file by exiting (selecting option 2). While the first operator is doing this, the second operator can try to access the data file mustock.dat, but the second operator will fail to gain access to this file at all. This is because opening a file for output locks the file exclusively. The second operator will receive a "file locked" status. Now that the operators have a data file they can share you can have them both accessing the data file mustock.dat at the same time. Sharing the File If operator one selects 2, for I-O Lock Mode Automatic at the initial screen, the new screen is displayed as shown in Figure 16-3 . To access the first record, the operator must move down to the Input Choice field by pressing End twice. Now press 2 to read the next record. The first record in mustock.dat is displayed.
[]
Figure 16-3. Preparing to Read the Next Record The first record in the data file mustock.dat is now locked by operator one, and remains so until this operator next accesses the file. Operator two can access any other record in the file by also selecting to open the file for I-O Lock Mode Automatic or for Input, for example. Operator two can execute a "start not less than", thus avoiding the first record in the file that is locked to operator one. Operator two may access the first record, but receives a file status of "Record locked" and the access is unsuccessful. However, the data will be returned unless the operating system does not support this. Try the various combinations of locking and access for yourself so that you become familiar with the way Micro Focus COBOL can lock data.


MPE/iX 5.0 Documentation