        **********  DATETEST COMMAND FILE  ***********
* This file verifies the Bill:Date and Check:Date to see that they are
* in the right format.  If incorrect, the operator may edit them.
********************************************************************

ERASE
GO TOP

* The variable DATE brings in the NAME of the date field to be checked
* from the command files where this is used.
DO WHILE .NOT. EOF
   @  6,30 SAY 'VERIFYING '+Date+' '

   IF *
      SKIP 
   ELSE
      IF &Date <> '  '
         STORE STR(#,5) TO Found
         STORE T TO NoDate
         DO WHILE NoDate
            @  8,30 SAY ' RECORD '+Found
            @  9,30 SAY ' '+$(&Date,1,2)+'/'+$(&Date,3,2)+'/'+$(&Date,5,2)
            ? CHR(7)
            * The macro symbol is use to get the contents of the date field
            * being checked without creating a new variable.
            IF VAL($(&Date,1,2)) > ThisYear .OR. VAL($(&Date,1,2)) < MinYear;
                  .OR. VAL($(&Date,3,2)) < 1 .OR. VAL($(&Date,3,2)) > 12;
                  .OR. VAL($(&Date,5,2)) < 1 .OR. VAL($(&Date,5,2)) > 31
               ?
               ?
               ? '                           DATE ERROR: Must be YYMMDD '
               ACCEPT 'Enter new Date' TO Temp
               REPLACE &Date WITH Temp
               ERASE
            ELSE
               STORE F TO NoDate
               SKIP
            ENDIF
         ENDDO NoDate
         RELEASE Temp, NoDate
      ELSE
         SKIP
      ENDIF date is not blank

      * Delay to allow date being checked to be read (quickly)
      STORE 0 TO X
      DO WHILE X < 5
         STORE (X + 1) TO X
      ENDDO

   ENDIF deleted or posted
ENDDO
RELEASE All
RETURN
