    ****************** COSTUPDATE COMMAND FILE ********************
*	Records from the COSTFILE (POSTFILE) are added to the COSTBASE.
* This step is so critical to data integrity that we: use a password
* to prevent accidential access; verify dates; check the names of suppliers;
* and compute time charges if necessary. Notice that these are done by
* simply calling the utility command files.
*	The PostFile has all its records marked for deletion after they
* have been posted (can still be recovered).
************************************************************************

SET TALK OFF

@  4,12 SAY '************************************************************'
@  6,12 SAY 'MAKE CERTAIN EVERYTHING IN THE POSTFILE IS CORRECT'
@  8,12 SAY '	BEFORE ENTERING THE CODE TO CONTINUE'
@ 10,12 SAY '************************************************************'
SET CONSOLE OFF
ACCEPT TO Lock
SET CONSOLE ON

IF !(Lock) <> 'H'
   @ 12,12 SAY '	UNAUTHORIZED ACCESS ATTEMPTED.'
   @ 14,12 SAY 'YOU HAVE 6 SECONDS BEFORE THE EXPLOSION. CODE = H'
   STORE 1 TO X 
   DO WHILE X < 150
      STORE X + 1 TO X
   ENDDO
   RELEASE Lock
   RETURN
ELSE
   ERASE
   @ 5,20 SAY 'Checking bills in the POSTING file:'
   USE B:PostFile
   COUNT FOR .NOT. * TO None
   IF None = 0
      @ 6,20 SAY 'No new entries in the POSTING file.'
      @ 7,20 SAY '<Return> to continue.'
      WAIT
   ELSE
      GO TOP
      RESTORE FROM B:Constant
      STORE 'Bill:Date' TO Date
      DO DateTest
      DO NameTest
      DO TimeCalc
      ERASE
      @ 5,20 SAY ' ***** DO NOT INTERRUPT *******'
      @ 6,20 SAY ' Posting COSTS to the Costbase.'
      * Save the number of the last record in Costbase
      USE B:CostBase 
      GO BOTTOM
      STORE # TO LastReco

      USE B:CostBase INDEX B:$Supp
      APPEND FROM B:Postfile
      INDEX ON NAME TO B:$SUPP

      USE B:PostFile
      DELETE ALL
   ENDIF
ENDIF

RELEASE ALL
RETURN
