(10-23-2022, 06:21 PM)bplus Wrote: Oh I am glad I read this before I started rewriting source programs!
Good catch Sir Pete!
@bplus
Well I think I have that worked out now.
ALSO, and this is a biggie...
After the program finishes the real lines are placed on your clipboard. You could try and copy the forum code for MG's shadow effects to your clipboard, run this app, open an IDE, and paste 155 un-colonized lines that should run the same as the original.
Now in DEBUG stage. Found one bug with failure to close IF/THEN tags in complex nested statement blocks.
Code: (Select All)
WIDTH 100, 25
_SCREENMOVE _MIDDLE
DIM i AS _INTEGER64
z$ = _CLIPBOARD$
x$ = UCASE$(_CLIPBOARD$)
IF RIGHT$(x$, 2) <> CHR$(13) + CHR$(10) THEN x$ = x$ + CHR$(13) + CHR$(10) ' Compensates for 1-line no return Notepad copy.
PRINT "Line count analysis...": PRINT
DO
LINE INPUT "Count statements beginning with REM or ' as a line? [Y] / [N]: "; rem_ans$: PRINT
rem_ans$ = UCASE$(rem_ans$)
IF INSTR("YN", rem_ans$) THEN EXIT DO
LOOP
PRINT "Press [1] to parse all colons. [2] to exclude colons in one-line IF/THEN statements.": PRINT
DO
_LIMIT 30
b$ = INKEY$
IF LEN(b$) THEN
SELECT CASE b$
CASE CHR$(27): SYSTEM
CASE "1": PRINT "Parsing all significant colons...": EXIT DO
CASE "2": myopt = -1: PRINT "Parsing all significant colons not used in IF/THEN one line statements.": EXIT DO
END SELECT
END IF
LOOP
PRINT
_KEYCLEAR
FOR i = 1 TO LEN(x$)
a$ = MID$(x$, i, 1)
IF a$ = CHR$(13) OR a$ = CHR$(10) THEN
IF a$ = CHR$(10) THEN
IF label_check THEN
tmp$ = _TRIM$(MID$(s$, INSTR(s$, ":") + 1))
IF MID$(tmp$, 1, 3) = "REM" OR LEFT$(tmp$, 1) = "'" OR tmp$ = CHR$(10) + CHR$(13) OR tmp$ = "" THEN ELSE MID$(z$, label_check, 1) = CHR$(0): c_cnt = c_cnt + 1
END IF
if_block$ = "": then_marker = 0
c$ = "": parse1$ = "": parse2$ = "": parse3$ = "": label_check = 0: ide_line_cnt = ide_line_cnt + 1
IF parse4$ = "off" THEN rem_lines = rem_lines + 1
IF LEN(s$) = 0 THEN blank_line_cnt = blank_line_cnt + 1
s$ = ""
ELSE
IF if_block$ = "on" THEN
MID$(z$, i, 1) = CHR$(255): MID$(z$, then_marker, 1) = CHR$(0): c_cnt = c_cnt + 1 ' Add one line for the END IF
if_block$ = "": then_marker = 0
END IF
END IF
ELSE
s$ = s$ + a$
c$ = c$ + a$
IF myopt THEN IF c$ = "THEN " THEN IF parse1$ = "" AND parse2$ = "" AND parse4$ = "" THEN parse3$ = "off"
IF myopt = 0 THEN IF c$ = "THEN " THEN then_marker = i
IF s$ = "$IF THEN" THEN parse4$ = "off": parse1$ = "": parse2$ = "": parse3$ = ""
IF a$ = "'" OR c$ = "REM " THEN
IF parse1$ = "" AND parse2$ = "" AND parse3$ = "" AND parse4$ = "" THEN parse1$ = "off"
IF _TRIM$(s$) = _TRIM$(c$) THEN rem_lines = rem_lines + 1
END IF
IF parse4$ = "off" THEN IF s$ = "$END IF " THEN parse4$ = ""
IF a$ = " " THEN c$ = ""
IF parse1$ <> "off" THEN
IF a$ = CHR$(34) THEN IF parse1$ = "" AND parse3$ = "" THEN IF parse2$ = "off" THEN parse2$ = "" ELSE parse2$ = "off"
IF parse2$ <> "off" THEN
IF parse3$ <> "off" THEN
IF parse4$ <> "off" THEN
IF myopt = 0 AND then_marker THEN IF a$ = ":" THEN IF if_block$ = "" THEN if_block$ = "on"
IF col$ = "on" THEN IF a$ <> " " AND a$ <> ":" THEN col$ = ""
IF a$ = ":" THEN ' Test for label.
IF INSTR(MID$(LTRIM$(s$), 1, INSTR(LTRIM$(s$), ":")), " ") = 0 THEN
label_check = i + 1
ELSE
IF col$ = "" THEN col$ = "on": c_cnt = c_cnt + 1: MID$(z$, i, 1) = CHR$(0)
END IF
END IF
END IF
END IF
END IF
END IF
END IF
IF a$ = "_" THEN IF MID$(x$, i + 1, 1) = CHR$(13) THEN IF parse1$ = "" AND parse2$ = "" AND parse3$ = "" THEN cont_lines = cont_lines + 1
NEXT
IF rem_ans$ = "Y" THEN
PRINT "IDE Lines ="; ide_line_cnt; " Statement Lines ="; ide_line_cnt - blank_line_cnt - cont_lines; " Real Lines ="; ide_line_cnt - blank_line_cnt - cont_lines + c_cnt
ELSE
PRINT "IDE Lines ="; ide_line_cnt; " Statement Lines Without Remark Lines ="; ide_line_cnt - blank_line_cnt - cont_lines - rem_lines; " Real Lines ="; ide_line_cnt - blank_line_cnt - cont_lines - rem_lines + c_cnt
END IF
_CLIPBOARD$ = ""
FOR i = 1 TO LEN(z$)
a$ = MID$(z$, i, 1)
IF a$ = CHR$(0) THEN
concat$ = concat$ + CHR$(13) + CHR$(10)
ELSEIF a$ = CHR$(255) THEN
concat$ = concat$ + CHR$(13) + "END IF"
ELSE
concat$ = concat$ + a$
END IF
NEXT
_CLIPBOARD$ = concat$
PRINT: PRINT "Program line rewrite was added to your clipboard."
Pete