'=========================================================================== ' Subject: DELETE COMMENTS IN BASIC FILES Date: 04-28-99 (07:08) ' Author: Alexander Meyer Code: QB, QBasic, PDS ' Origin: Meyer.Karl@t-online.de Packet: MISC.ABC '=========================================================================== ' //// ' 0(o o)0 '-------------------------ooO (_) Ooo--------------------- ' COMMENTS.BAS -- Written in QuickBasic 4.5 ' ' Name: Edit out comments ' Author: Alexander Meyer ' Date: 04-24-1999 ' Description: With this program, you can edit out the ' REM and ' comments in a QBasic file. ' 'For questions or comments mail to: Meyer.Karl@t-online.de '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CLS INPUT "Input the name of the BAS file (with extension): ", BASFile$ INPUT "Now input the name of the output file (with extension): ", OutputFile$ OPEN BASFile$ FOR INPUT AS #1 OPEN OutputFile$ FOR OUTPUT AS #2 DO WHILE NOT EOF(1) LINE INPUT #1, Text$ v% = v% + 1 LOCATE 4: PRINT "Working at line"; v% IF LEN(Text$) = 0 THEN 'Check if the line is empty PRINT #2, CHR$(13) GOTO OverJump END IF FOR m% = 1 TO LEN(Text$) 'Check if there's a meta command IF MID$(Text$, m%, 1) <> CHR$(32) THEN 'Edit out spaces in the line CM$ = CM$ + MID$(Text$, m%, 1) 'so that the meta commands END IF 'can be checked better NEXT m% IF MID$(CM$, 1, 10) = "REM$STATIC" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(CM$, 1, 11) = "REM$INCLUDE" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(CM$, 1, 11) = "REM$DYNAMIC" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(CM$, 1, 8) = "'$STATIC" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(CM$, 1, 9) = "'$INCLUDE" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(CM$, 1, 9) = "'$DYNAMIC" THEN : PRINT #2, Text$: GOTO OverJump IF MID$(Text$, 1, 1) = "'" OR MID$(Text$, 1, 4) = "REM " THEN GOTO OverJump FOR i% = 1 TO LEN(Text$) IF MID$(Text$, i%, 1) = CHR$(34) AND InString% = 1 THEN InString% = 0: GOTO InString 'Check if a REM or ' is in END IF 'a string IF MID$(Text$, i%, 1) = CHR$(34) AND InString% = 0 THEN InString% = 1: GOTO InString END IF InString: IF MID$(Text$, i%, 5) = "DATA " THEN InData% = 1 IF MID$(Text$, i%, 1) = "'" AND InString% = 0 AND InData% = 0 THEN PRINT #2, CHR$(13) 'Edit out EXIT FOR END IF IF MID$(Text$, i%, 1) = ":" AND MID$(Text$, i% + 2, 4) = "REM " AND InString% = 0 THEN PRINT #2, CHR$(13) EXIT FOR END IF GoOn: PRINT #2, MID$(Text$, i%, 1); 'When there was nothing IF i% = LEN(Text$) THEN PRINT #2, CHR$(13) NEXT i% OverJump: InString% = 0: CM$ = "": InData% = 0 LOOP CLOSE #2 CLOSE #1 PRINT "Done!" END