INV-INQ Program Example

The following program queries an inventory file.  It reads the dictionary of the INV file to get the attribute numbers of the part description (DESC) and the quantity-on-hand (QOH). It then prompts the user for a part number which is the item-id of an item in INV.  It uses the attribute numbers to read and display the part description and quantity-on-hand.  The program loops until a null part number is entered.

*** Get attribute definitions 
*** from DICT INV
OPEN 'DICT','INV' ELSE
    PRINT 'CANNOT OPEN "DICT INV"'; STOP
END
*
READV DESC.AMT FROM 'DESC',2 ELSE
    PRINT 'CANT READ "DESC" ATTR'; STOP
END
*
READV QOH.AMT FROM 'QOH',2 ELSE
    PRINT 'CANT READ "QOH" ATTR'; STOP
END
*
*** Open data portion of INV
OPEN 'INV' ELSE
    PRINT 'CANNOT OPEN "INV"'; STOP
END
*** Prompt for part number
LOOP
       PRINT
       PRINT 'PART-NUMBER ':
       INPUT PN
    WHILE PN # "" DO
       READ ITEM FROM PN THEN
           * PRINT DESCRIPTION AND 
           * QUANTITY ON HAND
           PRINT 'DESCRIPTION - ':
           PRINT ITEM<DESC.AMT>
           PRINT 'QTY-ON-HAND - ':
           PRINT ITEM<QOH.AMT>
       END ELSE
           PRINT 'CANNOT FIND THAT PART':
           PRINT ' ':PN
       END
REPEAT
END