NOTE |
Use of file update logic. This program updates data on lots in a housing tract. Item-IDs in the file LOT are TRACT.NAME*LOT.NUMBER. |
*** Initialization PROMPT '=' CLEAR DIM DESC(30), TYPE(30) OPEN 'DICT', 'LOT' TO DICTLOT ELSE PRINT "CAN'T OPEN DICT LOT" STOP END OPEN ",’LOT’ TO LOTFILE ELSE PRINT "CAN’T OPEN LOT FILE." STOP END *** Get descriptions, conversions 200 FOR I = 1 TO 30 READ DICT ITEM FROM DLOT,I ELSE PRINT "DICTIONARY ITEM '":I:"' NOT FOUND" END ELSE D = EXTRACT(DICT.ITEM,3,0,0) ; *S/NAME-- Description IF D # '' THEN DESC(I) = D:STR('.',15-LEN(D)) IF C[1,2] = 'MD' THEN TYPE(I) = 'NUM' END ELSE IF C[1,1] = '0' THEN TYPE(I) = 'DATE" END END NEXT I *** Get the tract name 300 PRINT PRINT "TRACT NAME.....": INPUT TRACT IF TRACT = 'STOP' OR TRACT = 'END' THEN STOP IF TRACT = '' THEN GOTO 300 READ INFO FROM TRACT ELSE PRINT "TRACT '":TRACT:"'LOT ON FILE" GOTO 300 END Get a valid lot number 400 PRINT PRINT "LOT NUMBER.....": INPUT NUMBER IF NUMBER = '' THEN GOTO 400 IF NUMBER = 'END' OR NUMBER = 'STOP' THEN GOTO 300 IF NUM(NUMBER) = 0 THEN PRINT "MUST BE A NUMBER" GOTO 400 END NUMBER = TRACT:'*':NUMBER READ ITEM FROM LOTFILE,NUMBER ELSE ITEM = '' PRINT "NEW LOT" END * NOT.SOLD = 0 FOR I = 1 TO 30 GOSUB 1000 ; * updates the i’th attribute IF I = 10 THEN IF EXTRACT(ITEM,10,0,0) = '' THEN NOT.SOLD = 1 I = 19 END END * IF I = 21 THEN IF NOT.SOLD THEN GOTO 500 END NEXT I *** Verify data & store 500 PRINT PRINT" OK ": INPUT OK IF OK = '' THEN WRITE ITEM ON NUMBER GOTO 400 END IF OK = 'L' THEN FOR L = 1 TO 30 ATT = EXTRACT(ITEM,I,0,0) IF ATT # ''THEN PRINT DESC(L): IF TYPE(L) = 'DATE' AND NUM(DATE) THEN ATT = OCONV(ATT,'DO') END IF TYPE(L) = 'NUM' AND NUM(ATT) THEN ATT = 0.01 * ATT END PRINT ATT 'R#15’ END NEXT L GOTO 500 END GOTO 400 *** Updates the i’th attribute of "ITEM" 1000 * IF DESC(I) = '' THEN RETURN ;*not needed or not found PRINT DESC(I): CURRENT = EXTRACT(ITEM,I,0,0) IF TYPE(I) = 'NUM' THEN ;*Need a number (amount) 1100 * PRINT CURRENT*.01 'R##############': INPUT RESPONSE IF RESPONSE = '' THEN RETURN ;* Just looking IF NUM(RESPONSE) = 0 THEN PRINT "MUST BE A NUMBER" GOTO 1100 END IF RESPONSE = ’\’ THEN ITEM = REPLACE(ITEM,I,0,0,'') RETURN ;* Delete this attribute END ITEM = REPLACE(ITEM,I,0,0,RESPONSE*100) RETURN END * IF TYPE(I) = 'DATE' THEN ;*Need a date 1200 * PRINT OCONV(CURRENT,'DO') 'R#14’: INPUT RESPONSE IF RESPONSE = '' THEN RETURN ;* Just looking IF RESPONSE = 'T' THEN ITEM = REPLACE(ITEM,I,0,0,") ;’*delete this attribute RETURN END IF RESPONSE = ’T’ THEN DATE = DATE() END ELSE DATE = ICONV(RESPNSE,’D’) IF DATE = " THEN PRINT "USE DATE FORMAT ’MONTH/DAY/YEAR’" GOTO 1200 END END ITEM = REPLACE(ITEM,I,0,0,DATE) RETURN END *** no necessary formats PRINT CURRENT 'R#15': INPUT RESPONSE IF RESPONSE = '' THEN RETURN IF RESPONSE = ’\’ THEN RESPONSE = '' ITEM = REPLACE(ITEM,I,0,0,RESPONSE) RETURN END |
See Also