ASSOC.INTEGRITY

From Pickwiki
Jump to navigationJump to search
      PROMPT ""
      PRINT "Please enter file name to verify: ":
      INPUT FILENAME

      EXECUTE "SELECT DICT ":FILENAME:" BY TYPE BY FIELD.NO BY F2 WITH TYPE EQ 'D' 'I'"
      READLIST KEYS THEN CONVERT @IM:@FM TO @VM:@VM IN KEYS
      IF KEYS EQ "" THEN STOP "No dictionary entries successfully selected!"
      OPEN "DICT", FILENAME TO DICTFILE ELSE STOP "Unable to open the dictionary"
      ASSOC.ENTRY = "" ; ASSOC.NAMES = ""
      LOOP
         REMOVE KEY FROM KEYS SETTING MER
         READ DICTENTRY FROM DICTFILE, KEY ELSE STOP "Unable to read ":KEY:" from dictionary!"
         BEGIN CASE
            CASE DICTENTRY<6> NE "M" AND DICTENTRY<7> NE ""
               WRITEV "" TO DICTFILE, KEY, 7
               PRINT "Deleted association from single-valued field ":KEY
            CASE DICTENTRY<7>
               LOCATE DICTENTRY<7> IN ASSOC.NAMES<1> BY "AL" SETTING POSN ELSE
                  INS DICTENTRY<7> BEFORE ASSOC.NAMES<POSN>
                  INS "" BEFORE ASSOC.ENTRY<POSN>
               END
               ASSOC.ENTRY<POSN,-1> = KEY
         END CASE
      WHILE MER REPEAT

      FOR II = 1 TO DCOUNT(ASSOC.NAMES, @FM)
         PRINT; PRINT ASSOC.NAMES<II>
         PRINT "PH Autogenerated by ASSOC.INTEGRITY":@FM:CONVERT(@VM, " ", ASSOC.ENTRY<II>)
         WRITE "PH Autogenerated by ASSOC.INTEGRITY":@FM:CONVERT(@VM, " ", ASSOC.ENTRY<II>) TO DICTFILE, ASSOC.NAMES<II>
      NEXT
      RETURN
   END