Program Real Line Counter. Anyone want to jump in?
#6
Try this...

Code: (Select All)
PRINT "Line count analysis...": PRINT

PRINT "Press [1] to parse all colons or [2] the exclude colons after an IF statement.": PRINT

DO
    _LIMIT 30
    b$ = INKEY$
    IF LEN(b$) THEN
        SELECT CASE b$
            CASE CHR$(27): SYSTEM
            CASE "1": myopt = 3: PRINT "Parsing all significant colons...": PRINT
            CASE "2": myopt = 4: PRINT "Parsing all significant colons not used in IF/THEN one line statements.": PRINT
        END SELECT
        IF myopt THEN EXIT DO
    END IF
LOOP

x$ = _CLIPBOARD$
IF RIGHT$(x$, 2) <> CHR$(13) + CHR$(10) THEN x$ = x$ + CHR$(13) + CHR$(10) ' Compenstates for 1-line no return Notepad copy.

DO
    ' parse clipboard
    statement$ = UCASE$(MID$(x$, 1, INSTR(x$, CHR$(13)) - 1))
    IF INSTR(statement$, CHR$(10)) THEN BEEP
    IF INSTR(statement$, CHR$(13)) THEN BEEP
    '''IF statement$ = CHR$(10) THEN statement$ = ""
    x$ = MID$(x$, INSTR(x$, CHR$(13)) + 2)

    IF LEN(_TRIM$(statement$)) THEN
        program_ide_lines = program_ide_lines + 1
        FOR i = 1 TO myopt
            SELECT CASE i
                CASE 1: mychr$ = CHR$(34)
                CASE 2: mychr$ = "'"
                CASE 3: mychr$ = "REM "
                CASE 4: mychr$ = " THEN "
            END SELECT

            SELECT CASE i
                CASE 1 '  Double polling for enclosed quotes.
                    DO UNTIL INSTR(statement$, mychr$) = 0
                        IF INSTR(statement$, mychr$) THEN
                            statement$ = MID$(statement$, 1, INSTR(statement$, mychr$) - 1) + MID$(statement$, INSTR(INSTR(statement$, mychr$) + 1, statement$, mychr$) + 1)
                        END IF
                    LOOP
                CASE ELSE
                    DO UNTIL INSTR(statement$, mychr$) = 0
                        IF INSTR(statement$, mychr$) THEN
                            statement$ = MID$(statement$, 1, INSTR(statement$, mychr$) - 1)
                        END IF
                    LOOP
            END SELECT
        NEXT
        IF RIGHT$(RTRIM$(statement$), 1) = ":" THEN statement$ = MID$(RTRIM$(statement$), 1, LEN(RTRIM$(statement$)) - 1)

        REM PRINT statement$,

        ' count colons

        seed% = 0: linecnt = linecnt + 1: real_line_cnt = real_line_cnt + 1
        DO UNTIL INSTR(seed%, statement$, ":") = 0
            seed% = INSTR(seed%, statement$, ":") + 1
            real_line_cnt = real_line_cnt + 1
        LOOP
    ELSE
        program_ide_lines = program_ide_lines + 1
    END IF

LOOP UNTIL x$ = ""
PRINT "Program IDE lines ="; program_ide_lines; "  Line count ="; linecnt; "  Real line count ="; real_line_cnt
If eggs are brain food, Biden takes his scrambled.
Reply


Messages In This Thread
RE: Program real Line counter. Anyone want to jump in. - by Pete - 10-22-2022, 09:17 PM



Users browsing this thread: 25 Guest(s)