'============================================================================== ' Source code: PowerBASIC for DOS ' ' Author: Egbert Zijlema (e.zylema@castel.nl) ' Copyright status: Public Domain ' ' Stores name constants (or equates) in KEYNAMES.INC ' Related article at: http://www.basicguru.com/zijlema/keyquate.htm '============================================================================== DEFINT A - Z CLS IF LEN(DIR$("KEYNAMES.INC")) THEN ' existing file? OPEN "KEYNAMES.INC" FOR BINARY AS #1 SEEK #1, 0 GET$ #1, LOF(1), DupeWatch$ ' grab entire contents CLOSE END IF OPEN "KEYNAMES.INC" FOR APPEND AS #1 LOCATE 25, 1 : PRINT "Equate generator by Egbert Zijlema"; LOCATE 2, 2 : PRINT "Name for the equate (type QUIT to quit): " DO DO LOCATE 2, 43 : PRINT SPACE$(37) ' clear row LOCATE 2, 43 LINE INPUT ""; KeyName$ LOOP UNTIL LEN(LTRIM$(RTRIM$(KeyName$))) IF UCASE$(LTRIM$(RTRIM$(KeyName$))) = "QUIT" THEN EXIT LOOP KeyName$ = "%" + UCASE$(LTRIM$(RTRIM$(KeyName$))) LOCATE 3, 2, 1 PRINT "Now press the key you want to connect with "; PRINT CHR$(34); KeyName$; CHR$(34); " (Esc = quit)"; CHR$(58, 32); ThisKey = GetKey IF ThisKey > 255 THEN KeyCode$ = LTRIM$(RTRIM$(STR$(ThisKey \ 256))) + " * 256" ELSE KeyCode$ = LTRIM$(RTRIM$(STR$(ThisKey))) END IF IF INSTR(1, DupeWatch$, KeyName$) = 0 AND _ INSTR(1, DupeWatch$, KeyCode$) = 0 THEN ' no duplicate? PRINT #1, KeyName$; " = "; KeyCode$ ' then append to file DupeWatch$ = DupeWatch$ + KeyName$ + _ " = " + KeyCode$ ' extend DupeWatch$ END IF LOCATE 3, 2 : PRINT SPACE$(79) ' clear row 3 LOOP UNTIL ThisKey = 27 CLOSE CLS END FUNCTION GetKey AS INTEGER DO LOOP UNTIL INSTAT FUNCTION = CVI(INKEY$ + CHR$(0)) END FUNCTION