* - EDIT.CMD
* - Called from main menu (MENU.CMD)
* - Uses B:FOG.DBF
* - Finds an entry and prompts for changes
*
SET BELL OFF
ERASE
STORE ' ' TO HIT
@ 10, 5 SAY ' DO YOU WISH TO UPDATE THE INDEX FILE (Y/N)'
@ 12, 5 SAY ' THIS NEEDS TO BE DONE ONLY IF YOU HAVE ADDED'
@ 13, 5 SAY ' RECORDS TO THE DATA BASE SINCE INDEX WAS LAST'
@ 14, 5 SAY ' UPDATED'
?
WAIT TO HIT
IF HIT = 'Y'
  ERASE
  @ 10, 5 SAY ' PLEASE WAIT WHILE INDEX FILE IS CREATED'
  @ 12, 5 SAY ' FILE WILL TAKE APPROX 4 MINUTES TO CREATE'
  @ 13, 5 SAY ' WILL REQUIRE APPROXIMATELY 8K OF BLANK SPACE'
  @ 14, 5 SAY ' ON THE B DRIVE FOR EACH 64K OF DATA BASE FILE'
  USE B:FOG 
  INDEX ON DATE TO B:DATE  
  ELSE
  USE B:FOG INDEX B:DATE
ENDIF
ERASE
STORE '        ' TO MDATE
@  2, 3 SAY "******** EDIT THE FOGHORN DATABASE *********"
@  3,13 SAY "PRESS <RETURN> TO EXIT"
@  8, 3 SAY "ENTER DATE OF RECORD TO BE UPDATED" GET MDATE;
                                             PICTURE '!!!!!!!!' 
@ 13, 3 SAY "********************************************"
READ
FIND &MDATE
*
* - Test for failure to find date
*
IF #=0
   ERASE
   @ 8, 3 SAY "CAN'T FIND THAT DATE...."
   @ 9, 3 SAY "RETURNING TO MAIN MENU"
   SET TALK OFF
   STORE 1 TO X
   DO WHILE X<100
      STORE X+1 TO X
   ENDDO
   SET TALK ON
   RETURN
ENDIF
*
* - Check to see if correct record found
*
STORE ' ' TO HIT
DO WHILE !(HIT) <> 'Y'
   ERASE
   @ 8, 0
   ? TOPIC
   ?
   ? SUBJECT
   @ 19, 1 SAY "IS THIS THE ONE? (Y/N)"
   WAIT TO HIT
   IF !(HIT) <> 'Y'
      SKIP
      *
      * - See if the next record has the same date
      *
      IF DATE <>'&MDATE'
        ERASE
        @ 8, 3 SAY "CAN'T FIND CORRECT ARTICLE"
        @ 9, 3 SAY "FOR THAT DATE."
        @ 11, 3 SAY "SELECT 'A' (ADD) FROM MAIN MENU"
        SET TALK OFF
        STORE 1 TO X
        DO WHILE X<150
          STORE X+1 TO X
        ENDDO
        SET TALK ON
        RETURN
      ENDIF
  ENDIF
ENDDO
*
* - Display the record for editing
   STORE ' ' TO DONE
   DO WHILE ! (DONE) <> 'Y'
      ERASE
      @  2, 0 SAY "HIT <CR> TO SKIP TO NEXT LINE"
      @  4, 0 SAY "       MAGAZINE " GET MAGAZINE
      @  5, 0 SAY "           DATE " GET DATE
      @  6, 0 SAY "           PAGE " GET PAGE
      @  7, 0 SAY "          TOPIC " GET TOPIC
      @  9, 0 SAY " 150 CHARACTERS MAY BE ENTERED IN NEXT FIELD"
      @ 10, 0 SAY " INSERT COMMAS (,) BETWEEN ENTRIES"
      @ 12, 0 SAY "        SUBJECT " GET SUBJECT
      @ 15, 0 SAY "       RESERVED " GET RESERVED
      READ
      *
      ? "ARE ALL THE FIELDS CORRECT? (Y/N)"
      SET CONSOLE OFF
      WAIT TO DONE
      SET CONSOLE ON
   ENDDO
   USE
   RELEASE ALL
   RETURN
