SE

From Pickwiki
Jump to navigationJump to search
SE - utility to evaluate all atb's in a dict.

***************************************************************************
* Program: SE
* Author : Ian [[McGowan]]
* Date   : 2/19/98
* Edited : 13:48:31 Feb 20 2001 By MGC
* Comment: Search a dictionary given an example
***************************************************************************
* Date       User  Description

NOPROMPT=""
FILE = FIELD(@SENTENCE," ",2)
OPEN FILE TO FVAR ELSE STOP 201,FILE
OPEN 'DICT', FILE TO @DICT ELSE STOP 201, 'DICT ':FILE
USE.ID=FIELD(@SENTENCE," ",3)
NOPROMPT=FIELD(@SENTENCE," ",4)   ;* don't execute ae if there is a noprompt option

PRINT "BUILDING LIST OF ATB'S"
FLD.LIST='' ; NUM.FLDS=0
EXECUTE \SSELECT DICT \:FILE
LOOP
   READNEXT FLD.NAME ELSE EXIT
   READ DREC FROM @DICT, FLD.NAME THEN
      IF DREC<1>='I' THEN
         CNV=DREC<3>
         IF CNV='' THEN CNV='*'
         INS FLD.NAME BEFORE FLD.LIST<1,-1>
         INS CNV BEFORE FLD.LIST<2,-1>
         NUM.FLDS+=1
      END
   END
REPEAT
PRINT NUM.FLDS:" FIELDS FOUND"
IF USE.ID # "" THEN E=\SELECT \:FILE:\ '\:USE.ID:\'\ ELSE E=\SELECT \:FILE:\ SAMPLE 1\
PRINT "SCANNING - ":E
EXECUTE E
READNEXT @ID ELSE STOP 'CANNOT READ ':FILE:' ':USE.ID
RESULT.REC=""
RESULT.REC="@ID=":@ID
RESULT.REC<-1>="FILE=":FILE
PRINT @ID
READ @RECORD FROM FVAR, @ID ELSE STOP 'ERROR READING ':@ID
FOR F=1 TO NUM.FLDS
   FLD.NAME=FLD.LIST<1,F>
   PRINT "FLD: ":FLD.NAME
   CONV=FLD.LIST<2,F>
   IF CONV # '*' THEN
      RESULT=OCONV(CALCULATE(FLD.NAME),CONV)
   END ELSE
      RESULT=CALCULATE(FLD.NAME)
   END
   RESULT.REC<-1>=FLD.NAME:"=":RESULT
NEXT F

OPEN 'VOC' TO VOC THEN
   WRITE RESULT.REC ON VOC, 'RESULT.REC'
   IF NOPROMPT="" THEN EXECUTE 'AE VOC RESULT.REC'
END