From 47685d82b07b7f42d3edfc01a83c1f2107712d17 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Nov 2018 00:47:46 -0200 Subject: [PATCH 01/10] Implements unused variables indicator An arrow to the left of the line where a variable was defined will be shown after compilation to indicate that variable hasn't been used throughout the program. --- source/ide/ide_methods.bas | 57 ++++++++++++++++++++++++- source/qb64.bas | 85 +++++++++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 4 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 6fe6ddec5..c74fe6dbe 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1255,8 +1255,17 @@ FUNCTION ide2 (ignore) QuickNavHover = -1 LOCATE 2, 4 COLOR 15, 3 - PRINT " " + CHR$(17) + " back to line "; str2$(QuickNavHistory(QuickNavTotal)); " "; + popup$ = " " + CHR$(17) + " back to line " + str2$(QuickNavHistory(QuickNavTotal)) + " " + PRINT popup$; + + 'shadow + COLOR 2, 0 + FOR x2 = 6 TO 4 + LEN(popup$) + LOCATE 3, x2: PRINT CHR$(SCREEN(3, x2)); + NEXT + PCOPY 3, 0 + IF mB THEN ideselect = 0 idecy = QuickNavHistory(QuickNavTotal) @@ -1269,6 +1278,7 @@ FUNCTION ide2 (ignore) QuickNavHover = 0 GOSUB UpdateTitleOfMainWindow GOSUB DrawQuickNav + ideshowtext PCOPY 3, 0 END IF END IF @@ -1277,11 +1287,44 @@ FUNCTION ide2 (ignore) QuickNavHover = 0 GOSUB UpdateTitleOfMainWindow GOSUB DrawQuickNav + ideshowtext PCOPY 3, 0 END IF END IF END IF + IF mX > 0 AND mY > 0 THEN + IF showingUnusedVariableWarning = 0 THEN + IF mX = 1 AND SCREEN(mY, mX) = 26 THEN + unusedVariableWarningX = mX + unusedVariableWarningY = mY + findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2)) + unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(10)) - findItem - 6) + findItem = INSTR(unusedVariableName$, CHR$(3)) + unusedVariableName$ = LEFT$(unusedVariableName$, findItem - 1) + " (" + MID$(unusedVariableName$, findItem + 1) + ") " + unusedVariableWarning$ = LEFT$(" Variable hasn't yet been used: " + unusedVariableName$, idewx - 2) + LOCATE mY, mX + COLOR 0, 3 + PRINT CHR$(26) + unusedVariableWarning$ + + 'shadow + COLOR 2, 0 + FOR x2 = mX + 2 TO mX + LEN(unusedVariableWarning$) + 1 + LOCATE mY + 1, x2: PRINT CHR$(SCREEN(mY + 1, x2)); + NEXT + + PCOPY 3, 0 + showingUnusedVariableWarning = -1 + END IF + ELSE + IF unusedVariableWarningX <> mX OR unusedVariableWarningY <> mY THEN + ideshowtext + PCOPY 3, 0 + showingUnusedVariableWarning = 0 + END IF + END IF + END IF + IF _WINDOWHASFOCUS THEN LOCATE , , 1 _PALETTECOLOR 5, IDEBracketHighlightColor, 0 @@ -8498,6 +8541,14 @@ SUB ideshowtext END IF IF l <= iden THEN + IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2)) > 0 THEN + LOCATE y + 3, 1 + prevBG% = _BACKGROUNDCOLOR + COLOR 13, 1 + PRINT CHR$(26); 'indicate there's an unused variable defined on this line + COLOR , prevBG% + END IF + a$ = idegetline(l) link_idecx = 0 rgb_idecx = 0 @@ -8878,7 +8929,9 @@ SUB ideshowtext FOR b = 1 TO IdeBmkN y = IdeBmk(b).y IF y >= idesy AND y <= idesy + (idewy - 9) THEN - LOCATE 3 + y - idesy, 1: PRINT CHR$(197); + IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2)) = 0 THEN + LOCATE 3 + y - idesy, 1: PRINT CHR$(197); + END IF END IF NEXT diff --git a/source/qb64.bas b/source/qb64.bas index 353a4276e..fd8277f30 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -111,6 +111,8 @@ IF OS_BITS = 32 THEN _TITLE "QB64 x32" ELSE _TITLE "QB64 x64" DIM SHARED ConsoleMode, No_C_Compile_Mode, Cloud, NoIDEMode DIM SHARED CMDLineFile AS STRING +DIM SHARED totalUnusedVariables AS LONG, usedVariableList$, bypassNextVariable AS _BYTE +DIM SHARED warning$(100), totalWarnings AS LONG DIM SHARED ExeIconSet AS LONG DIM SHARED VersionInfoSet AS _BYTE @@ -1429,7 +1431,9 @@ subfunc = "" SelectCaseCounter = 0 ExecCounter = 0 UserDefineCount = 6 - +usedVariableList$ = "" +totalUnusedVariables = 0 +totalWarnings = 0 ''create a type for storing memory blocks ''UDT @@ -7280,6 +7284,7 @@ DO 'create variable IF LEN(s$) THEN typ$ = s$ ELSE typ$ = t$ IF optionexplicit THEN a$ = "Variable '" + n$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": GOTO errmes + bypassNextVariable = -1 retval = dim2(n$, typ$, method, "") IF Error_Happened THEN GOTO errmes 'note: variable created! @@ -14725,6 +14730,11 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) Give_Error "Unknown type": EXIT FUNCTION dim2exitfunc: + IF bypassNextVariable = 0 THEN + manageVariableList cvarname$, n$, 0 + END IF + bypassNextVariable = 0 + IF dimsfarray THEN ids(idn).sfid = glinkid ids(idn).sfarg = glinkarg @@ -15116,6 +15126,7 @@ FUNCTION evaluate$ (a2$, typ AS LONG) END IF 'varname NEXT END IF 'subfuncn + bypassNextVariable = -1 ignore = dim2(l$, dtyp$, method, fakee$) IF Error_Happened THEN EXIT FUNCTION dimstatic = olddimstatic @@ -15310,6 +15321,7 @@ FUNCTION evaluate$ (a2$, typ AS LONG) IF Debug THEN PRINT #9, "CREATING VARIABLE:" + x$ IF optionexplicit THEN Give_Error "Variable '" + x$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": EXIT FUNCTION + bypassNextVariable = -1 retval = dim2(x$, typ$, 1, "") IF Error_Happened THEN EXIT FUNCTION @@ -17736,6 +17748,32 @@ FUNCTION findid& (n2$) id = ids(i) + t = id.t + IF t = 0 THEN + t = id.arraytype + IF t AND ISUDT THEN + manageVariableList "", scope$ + "ARRAY_UDT_" + RTRIM$(id.n), 2 + ELSE + n$ = id2fulltypename$ + IF LEFT$(n$, 1) = "_" THEN + manageVariableList "", scope$ + "ARRAY" + n$ + "_" + RTRIM$(id.n), 2 + ELSE + manageVariableList "", scope$ + "ARRAY_" + n$ + "_" + RTRIM$(id.n), 2 + END IF + END IF + ELSE + IF t AND ISUDT THEN + manageVariableList "", scope$ + "UDT_" + RTRIM$(id.n), 2 + ELSE + n$ = id2fulltypename$ + IF LEFT$(n$, 1) = "_" THEN + manageVariableList "", scope$ + MID$(n$, 2) + "_" + RTRIM$(id.n), 2 + ELSE + manageVariableList "", scope$ + n$ + "_" + RTRIM$(id.n), 2 + END IF + END IF + END IF + currentid = i EXIT FUNCTION @@ -21255,7 +21293,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) getid idnumber IF Error_Happened THEN EXIT SUB - 'UDT? IF typ AND ISUDT THEN @@ -21345,6 +21382,8 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'print "setUDTrefer:"+r$,e$ tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + manageVariableList "", scope$ + n$, 1 EXIT SUB END IF @@ -21378,6 +21417,8 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) END IF PRINT #12, cleanupstringprocessingcall$ + "0);" tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + manageVariableList "", r$, 1 EXIT SUB END IF @@ -21452,6 +21493,8 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) PRINT #12, cleanupstringprocessingcall$ + "0);" IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + manageVariableList "", r$, 1 EXIT SUB END IF @@ -21482,6 +21525,8 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + manageVariableList "", r$, 1 EXIT SUB END IF @@ -21508,6 +21553,10 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF stringprocessinghappened THEN PRINT #12, cleanupstringprocessingcall$ + "0);": stringprocessinghappened = 0 IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ + + IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) + manageVariableList "", r$, 1 + EXIT SUB END IF 'variable @@ -24789,6 +24838,38 @@ SUB dump_udts CLOSE #f END SUB +SUB manageVariableList (name$, __cname$, action AS _BYTE) + DIM findItem AS LONG, s$, cname$ + cname$ = __cname$ + + findItem = INSTR(cname$, "[") + IF findItem THEN + cname$ = LEFT$(cname$, findItem - 1) + END IF + + SELECT CASE action + CASE 0 'add + usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2) + usedVariableList$ = usedVariableList$ + name$ + CHR$(3) + cname$ + CHR$(10) + totalUnusedVariables = totalUnusedVariables + 1 + 'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + CASE ELSE 'find and remove + s$ = CHR$(3) + cname$ + CHR$(10) + findItem = INSTR(usedVariableList$, s$) + IF findItem THEN + FOR i = findItem TO 1 STEP -1 + IF ASC(usedVariableList$, i) = 1 THEN + findItem = INSTR(findItem, usedVariableList$, CHR$(10)) + usedVariableList$ = LEFT$(usedVariableList$, i - 1) + MID$(usedVariableList$, findItem + 1) + totalUnusedVariables = totalUnusedVariables - 1 + EXIT FOR + END IF + NEXT + END IF + 'usedVariableList$ = usedVariableList$ + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + END SELECT +END SUB + '$INCLUDE:'utilities\strings.bas' '$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas' From 738fe6924dc27784ded377c83f7b3888db37221e Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 31 Dec 2018 21:00:16 -0200 Subject: [PATCH 02/10] Improved detection of unused variables. --- source/ide/ide_methods.bas | 14 ++++++++------ source/qb64.bas | 29 +++++++++++++++-------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index c74fe6dbe..724b6f40d 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1298,14 +1298,16 @@ FUNCTION ide2 (ignore) IF mX = 1 AND SCREEN(mY, mX) = 26 THEN unusedVariableWarningX = mX unusedVariableWarningY = mY - findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2)) - unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(10)) - findItem - 6) - findItem = INSTR(unusedVariableName$, CHR$(3)) + findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2) + CHR$(3)) + unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(5)) - findItem - 6) + findItem = MID$(usedVariableList$, findItem + 6 + LEN(unusedVariableName$) INSTR(findItem, usedVariableList$, CHR$(3)) unusedVariableName$ = LEFT$(unusedVariableName$, findItem - 1) + " (" + MID$(unusedVariableName$, findItem + 1) + ") " unusedVariableWarning$ = LEFT$(" Variable hasn't yet been used: " + unusedVariableName$, idewx - 2) LOCATE mY, mX COLOR 0, 3 - PRINT CHR$(26) + unusedVariableWarning$ + PRINT CHR$(26) + LEFT$(unusedVariableWarning$, 32); + COLOR 15 + PRINT MID$(unusedVariableWarning$, 33); 'shadow COLOR 2, 0 @@ -8541,7 +8543,7 @@ SUB ideshowtext END IF IF l <= iden THEN - IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2)) > 0 THEN + IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + CHR$(4)) > 0 THEN LOCATE y + 3, 1 prevBG% = _BACKGROUNDCOLOR COLOR 13, 1 @@ -8929,7 +8931,7 @@ SUB ideshowtext FOR b = 1 TO IdeBmkN y = IdeBmk(b).y IF y >= idesy AND y <= idesy + (idewy - 9) THEN - IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2)) = 0 THEN + IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + CHR$(4)) = 0 THEN LOCATE 3 + y - idesy, 1: PRINT CHR$(197); END IF END IF diff --git a/source/qb64.bas b/source/qb64.bas index fd8277f30..8c21c2cf3 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -11631,7 +11631,10 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log - +OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1 +OPEN "unusedVariableList.txt" FOR BINARY AS #1 +PUT #1, 1, usedVariableList$ +CLOSE #1 @@ -24849,22 +24852,20 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) SELECT CASE action CASE 0 'add - usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2) - usedVariableList$ = usedVariableList$ + name$ + CHR$(3) + cname$ + CHR$(10) - totalUnusedVariables = totalUnusedVariables + 1 - 'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + s$ = CHR$(4) + MKI$(LEN(cname$)) + cname$ + CHR$(5) + IF INSTR(usedVariableList$, s$) = 0 THEN + ASC(s$, 1) = 3 + usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2) + usedVariableList$ = usedVariableList$ + s$ + name$ + CHR$(10) + totalUnusedVariables = totalUnusedVariables + 1 + 'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + END IF CASE ELSE 'find and remove - s$ = CHR$(3) + cname$ + CHR$(10) + s$ = CHR$(3) + cname$ + CHR$(5) findItem = INSTR(usedVariableList$, s$) IF findItem THEN - FOR i = findItem TO 1 STEP -1 - IF ASC(usedVariableList$, i) = 1 THEN - findItem = INSTR(findItem, usedVariableList$, CHR$(10)) - usedVariableList$ = LEFT$(usedVariableList$, i - 1) + MID$(usedVariableList$, findItem + 1) - totalUnusedVariables = totalUnusedVariables - 1 - EXIT FOR - END IF - NEXT + ASC(usedVariableList$, findItem) = 4 + totalUnusedVariables = totalUnusedVariables - 1 END IF 'usedVariableList$ = usedVariableList$ + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10) END SELECT From da24fde08dbfc396aefc5149cc23c56d6a2ed261 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 15:28:08 -0200 Subject: [PATCH 03/10] Properly add/remove variables from usedVariableList$ --- source/ide/ide_methods.bas | 38 ++------------------------------------ source/qb64.bas | 16 ++++++++-------- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 724b6f40d..2983006e8 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1293,40 +1293,6 @@ FUNCTION ide2 (ignore) END IF END IF - IF mX > 0 AND mY > 0 THEN - IF showingUnusedVariableWarning = 0 THEN - IF mX = 1 AND SCREEN(mY, mX) = 26 THEN - unusedVariableWarningX = mX - unusedVariableWarningY = mY - findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2) + CHR$(3)) - unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(5)) - findItem - 6) - findItem = MID$(usedVariableList$, findItem + 6 + LEN(unusedVariableName$) INSTR(findItem, usedVariableList$, CHR$(3)) - unusedVariableName$ = LEFT$(unusedVariableName$, findItem - 1) + " (" + MID$(unusedVariableName$, findItem + 1) + ") " - unusedVariableWarning$ = LEFT$(" Variable hasn't yet been used: " + unusedVariableName$, idewx - 2) - LOCATE mY, mX - COLOR 0, 3 - PRINT CHR$(26) + LEFT$(unusedVariableWarning$, 32); - COLOR 15 - PRINT MID$(unusedVariableWarning$, 33); - - 'shadow - COLOR 2, 0 - FOR x2 = mX + 2 TO mX + LEN(unusedVariableWarning$) + 1 - LOCATE mY + 1, x2: PRINT CHR$(SCREEN(mY + 1, x2)); - NEXT - - PCOPY 3, 0 - showingUnusedVariableWarning = -1 - END IF - ELSE - IF unusedVariableWarningX <> mX OR unusedVariableWarningY <> mY THEN - ideshowtext - PCOPY 3, 0 - showingUnusedVariableWarning = 0 - END IF - END IF - END IF - IF _WINDOWHASFOCUS THEN LOCATE , , 1 _PALETTECOLOR 5, IDEBracketHighlightColor, 0 @@ -8543,7 +8509,7 @@ SUB ideshowtext END IF IF l <= iden THEN - IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + CHR$(4)) > 0 THEN + IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + CHR$(3)) > 0 THEN LOCATE y + 3, 1 prevBG% = _BACKGROUNDCOLOR COLOR 13, 1 @@ -8931,7 +8897,7 @@ SUB ideshowtext FOR b = 1 TO IdeBmkN y = IdeBmk(b).y IF y >= idesy AND y <= idesy + (idewy - 9) THEN - IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + CHR$(4)) = 0 THEN + IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + CHR$(3)) = 0 THEN LOCATE 3 + y - idesy, 1: PRINT CHR$(197); END IF END IF diff --git a/source/qb64.bas b/source/qb64.bas index cd5de8a46..369af5ede 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -11631,10 +11631,10 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log -OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1 -OPEN "unusedVariableList.txt" FOR BINARY AS #1 -PUT #1, 1, usedVariableList$ -CLOSE #1 +'OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1 +'OPEN "unusedVariableList.txt" FOR BINARY AS #1 +'PUT #1, 1, usedVariableList$ +'CLOSE #1 @@ -17141,10 +17141,10 @@ FUNCTION evaluatetotyp$ (a2$, targettyp AS LONG) IF E = 0 THEN 'no specific element, use size of entire type bytes$ = str2(udtxsize(u) \ 8) ELSE 'a specific element - if (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -5) then + IF (udtetype(E) AND ISSTRING) > 0 AND (udtetype(E) AND ISFIXEDLENGTH) = 0 AND (targettyp = -5) THEN evaluatetotyp$ = "(*(qbs**)" + dst$ + ")->len" - exit function - end if + EXIT FUNCTION + END IF bytes$ = str2(udtesize(E) \ 8) END IF evaluatetotyp$ = "byte_element((uint64)" + dst$ + "," + bytes$ + "," + NewByteElement$ + ")" @@ -24887,7 +24887,7 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) 'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) END IF CASE ELSE 'find and remove - s$ = CHR$(3) + cname$ + CHR$(5) + s$ = CHR$(3) + MKI$(LEN(cname$)) + cname$ + CHR$(5) findItem = INSTR(usedVariableList$, s$) IF findItem THEN ASC(usedVariableList$, findItem) = 4 From a2114840de78a1c4a0924be704ecf17d4b146058 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 15:52:31 -0200 Subject: [PATCH 04/10] Shows warning when there are unused variables at CL compilation. Also adds -v switch for verbose mode (lists unused variables). --- source/qb64.bas | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 369af5ede..abb120cf1 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -109,7 +109,7 @@ OS_BITS = 64: IF INSTR(_OS$, "[32BIT]") THEN OS_BITS = 32 IF OS_BITS = 32 THEN _TITLE "QB64 x32" ELSE _TITLE "QB64 x64" DIM SHARED ConsoleMode, No_C_Compile_Mode, Cloud, NoIDEMode -DIM SHARED CMDLineFile AS STRING +DIM SHARED VerboseMode AS _BYTE, CMDLineFile AS STRING DIM SHARED totalUnusedVariables AS LONG, usedVariableList$, bypassNextVariable AS _BYTE DIM SHARED warning$(100), totalWarnings AS LONG @@ -11636,12 +11636,29 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log 'PUT #1, 1, usedVariableList$ 'CLOSE #1 - - IF idemode THEN GOTO ideret5 ide6: +IF totalUnusedVariables > 0 AND idemode = 0 THEN + PRINT "WARNING:"; STR$(totalUnusedVariables); " UNUSED VARIABLES"; + IF VerboseMode THEN + PRINT ":" + findItem = 0 + DO + s$ = CHR$(2) + CHR$(3) + findItem = INSTR(findItem + 1, usedVariableList$, s$) + IF findItem = 0 THEN EXIT DO + whichLine = CVL(MID$(usedVariableList$, findItem - 4, 4)) + varNameLen = CVI(MID$(usedVariableList$, findItem + 2, 2)) + varname$ = MID$(usedVariableList$, findItem + 4, varNameLen) + PRINT SPACE$(4); varname$; " (line"; STR$(whichLine); ")" + LOOP + ELSE + PRINT + END IF +END IF + IF idemode = 0 AND No_C_Compile_Mode = 0 THEN PRINT @@ -12691,6 +12708,7 @@ FUNCTION ParseCMDLineArgs$ () PRINT PRINT "OPTIONS:" PRINT " Source file to load" ' '80 columns + PRINT " -v Verbose mode (detailed warnings)" PRINT " -c Compile instead of edit" PRINT " -x Compile instead of edit and output the result to the" PRINT " console" @@ -12704,6 +12722,8 @@ FUNCTION ParseCMDLineArgs$ () PRINT " -l: Starts the IDE at the specified line number" PRINT SYSTEM + CASE "-v" 'Verbose mode + VerboseMode = -1 CASE "-p" 'Purge IF os$ = "WIN" THEN CHDIR "internal\c" From fb346b2164c22e164ebdbfcc78605900177366b2 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 16:59:30 -0200 Subject: [PATCH 05/10] Reset uniquenumbern when compilation restarts. --- source/qb64.bas | 1 + 1 file changed, 1 insertion(+) diff --git a/source/qb64.bas b/source/qb64.bas index abb120cf1..ef28a67cf 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -1434,6 +1434,7 @@ UserDefineCount = 6 usedVariableList$ = "" totalUnusedVariables = 0 totalWarnings = 0 +uniquenumbern = 0 ''create a type for storing memory blocks ''UDT From d194cc8039399ea739fafbc557a8a165f5d5b0bd Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 17:00:04 -0200 Subject: [PATCH 06/10] Displays normal and internal unused variable names in verbose warning. --- source/qb64.bas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index ef28a67cf..7222dcf2c 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -11642,6 +11642,7 @@ ide6: IF totalUnusedVariables > 0 AND idemode = 0 THEN + PRINT PRINT "WARNING:"; STR$(totalUnusedVariables); " UNUSED VARIABLES"; IF VerboseMode THEN PRINT ":" @@ -11652,8 +11653,10 @@ IF totalUnusedVariables > 0 AND idemode = 0 THEN IF findItem = 0 THEN EXIT DO whichLine = CVL(MID$(usedVariableList$, findItem - 4, 4)) varNameLen = CVI(MID$(usedVariableList$, findItem + 2, 2)) - varname$ = MID$(usedVariableList$, findItem + 4, varNameLen) - PRINT SPACE$(4); varname$; " (line"; STR$(whichLine); ")" + internalVarName$ = MID$(usedVariableList$, findItem + 4, varNameLen) + findLF = INSTR(findItem + 5 + varNameLen, usedVariableList$, CHR$(10)) + varname$ = MID$(usedVariableList$, findItem + 5 + varNameLen, findLF - (findItem + 5 + varNameLen)) + PRINT SPACE$(4); varname$; " ("; internalVarName$; ", line"; STR$(whichLine); ")" LOOP ELSE PRINT From 639b7549d79a0a51b84f975586a574eb29f76834 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 17:50:51 -0200 Subject: [PATCH 07/10] Fixes incorrect detection of unused _UNSIGNED and fixed length vars. --- source/qb64.bas | 73 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 7222dcf2c..a6fb02946 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -112,7 +112,7 @@ DIM SHARED ConsoleMode, No_C_Compile_Mode, Cloud, NoIDEMode DIM SHARED VerboseMode AS _BYTE, CMDLineFile AS STRING DIM SHARED totalUnusedVariables AS LONG, usedVariableList$, bypassNextVariable AS _BYTE -DIM SHARED warning$(100), totalWarnings AS LONG +DIM SHARED totalWarnings AS LONG DIM SHARED ExeIconSet AS LONG DIM SHARED VersionInfoSet AS _BYTE @@ -1434,6 +1434,7 @@ UserDefineCount = 6 usedVariableList$ = "" totalUnusedVariables = 0 totalWarnings = 0 +REDIM SHARED warning$(100) uniquenumbern = 0 ''create a type for storing memory blocks @@ -11634,7 +11635,7 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log 'OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1 'OPEN "unusedVariableList.txt" FOR BINARY AS #1 -'PUT #1, 1, usedVariableList$ +'PUT #1, 1, warning$(1) 'CLOSE #1 IF idemode THEN GOTO ideret5 @@ -17788,24 +17789,24 @@ FUNCTION findid& (n2$) IF t = 0 THEN t = id.arraytype IF t AND ISUDT THEN - manageVariableList "", scope$ + "ARRAY_UDT_" + RTRIM$(id.n), 2 + manageVariableList "", scope$ + "ARRAY_UDT_" + RTRIM$(id.n), 1 ELSE - n$ = id2fulltypename$ + n$ = id2shorttypename$ IF LEFT$(n$, 1) = "_" THEN manageVariableList "", scope$ + "ARRAY" + n$ + "_" + RTRIM$(id.n), 2 ELSE - manageVariableList "", scope$ + "ARRAY_" + n$ + "_" + RTRIM$(id.n), 2 + manageVariableList "", scope$ + "ARRAY_" + n$ + "_" + RTRIM$(id.n), 3 END IF END IF ELSE IF t AND ISUDT THEN - manageVariableList "", scope$ + "UDT_" + RTRIM$(id.n), 2 + manageVariableList "", scope$ + "UDT_" + RTRIM$(id.n), 4 ELSE - n$ = id2fulltypename$ + n$ = id2shorttypename$ IF LEFT$(n$, 1) = "_" THEN - manageVariableList "", scope$ + MID$(n$, 2) + "_" + RTRIM$(id.n), 2 + manageVariableList "", scope$ + MID$(n$, 2) + "_" + RTRIM$(id.n), 5 ELSE - manageVariableList "", scope$ + n$ + "_" + RTRIM$(id.n), 2 + manageVariableList "", scope$ + n$ + "_" + RTRIM$(id.n), 6 END IF END IF END IF @@ -21419,7 +21420,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'print "setUDTrefer:"+r$,e$ tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", scope$ + n$, 1 + manageVariableList "", scope$ + n$, 7 EXIT SUB END IF @@ -21454,7 +21455,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) PRINT #12, cleanupstringprocessingcall$ + "0);" tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 1 + manageVariableList "", r$, 8 EXIT SUB END IF @@ -21530,7 +21531,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 1 + manageVariableList "", r$, 9 EXIT SUB END IF @@ -21562,7 +21563,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 1 + manageVariableList "", r$, 10 EXIT SUB END IF @@ -21591,7 +21592,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 1 + manageVariableList "", r$, 11 EXIT SUB END IF 'variable @@ -23243,6 +23244,45 @@ FUNCTION id2fulltypename$ id2fulltypename$ = a$ END FUNCTION +FUNCTION id2shorttypename$ + t = id.t + IF t = 0 THEN t = id.arraytype + size = id.tsize + bits = t AND 511 + IF t AND ISUDT THEN + a$ = RTRIM$(udtxcname(t AND 511)) + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISSTRING THEN + IF t AND ISFIXEDLENGTH THEN a$ = "STRING" + str2(size) ELSE a$ = "STRING" + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISOFFSETINBITS THEN + IF t AND ISUNSIGNED THEN a$ = "_U" ELSE a$ = "_" + IF bits > 1 THEN a$ = a$ + "BIT" + str2(bits) ELSE a$ = a$ + "BIT1" + id2shorttypename$ = a$: EXIT FUNCTION + END IF + IF t AND ISFLOAT THEN + IF bits = 32 THEN a$ = "SINGLE" + IF bits = 64 THEN a$ = "DOUBLE" + IF bits = 256 THEN a$ = "_FLOAT" + ELSE 'integer-based + IF bits = 8 THEN + IF (t AND ISUNSIGNED) THEN a$ = "_UBYTE" ELSE a$ = "_BYTE" + END IF + IF bits = 16 THEN + IF (t AND ISUNSIGNED) THEN a$ = "UINTEGER" ELSE a$ = "INTEGER" + END IF + IF bits = 32 THEN + IF (t AND ISUNSIGNED) THEN a$ = "ULONG" ELSE a$ = "LONG" + END IF + IF bits = 64 THEN + IF (t AND ISUNSIGNED) THEN a$ = "_UINTEGER64" ELSE a$ = "_INTEGER64" + END IF + END IF + id2shorttypename$ = a$ +END FUNCTION + FUNCTION symbol2fulltypename$ (s2$) 'note: accepts both symbols and type names s$ = s2$ @@ -24908,16 +24948,17 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2) usedVariableList$ = usedVariableList$ + s$ + name$ + CHR$(10) totalUnusedVariables = totalUnusedVariables + 1 - 'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + 'warning$(1) = warning$(1) + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) END IF CASE ELSE 'find and remove + s$ = CHR$(3) + MKI$(LEN(cname$)) + cname$ + CHR$(5) findItem = INSTR(usedVariableList$, s$) IF findItem THEN ASC(usedVariableList$, findItem) = 4 totalUnusedVariables = totalUnusedVariables - 1 END IF - 'usedVariableList$ = usedVariableList$ + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10) + 'warning$(1) = warning$(1) + "Action:" + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10) END SELECT END SUB From a0373492df79a9d865786ea381412557292487b4 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 20:55:38 -0200 Subject: [PATCH 08/10] Refines warning output for unused variables (command line). --- source/qb64.bas | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index a6fb02946..226e25713 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -11635,7 +11635,7 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log 'OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1 'OPEN "unusedVariableList.txt" FOR BINARY AS #1 -'PUT #1, 1, warning$(1) +'PUT #1, 1, usedVariableList$ 'warning$(1) 'CLOSE #1 IF idemode THEN GOTO ideret5 @@ -11649,14 +11649,14 @@ IF totalUnusedVariables > 0 AND idemode = 0 THEN PRINT ":" findItem = 0 DO - s$ = CHR$(2) + CHR$(3) + s$ = CHR$(2) + "VAR:" + CHR$(3) findItem = INSTR(findItem + 1, usedVariableList$, s$) IF findItem = 0 THEN EXIT DO whichLine = CVL(MID$(usedVariableList$, findItem - 4, 4)) - varNameLen = CVI(MID$(usedVariableList$, findItem + 2, 2)) - internalVarName$ = MID$(usedVariableList$, findItem + 4, varNameLen) - findLF = INSTR(findItem + 5 + varNameLen, usedVariableList$, CHR$(10)) - varname$ = MID$(usedVariableList$, findItem + 5 + varNameLen, findLF - (findItem + 5 + varNameLen)) + varNameLen = CVI(MID$(usedVariableList$, findItem + 6, 2)) + internalVarName$ = MID$(usedVariableList$, findItem + 8, varNameLen) + findLF = INSTR(findItem + 9 + varNameLen, usedVariableList$, CHR$(10)) + varname$ = MID$(usedVariableList$, findItem + 9 + varNameLen, findLF - (findItem + 9 + varNameLen)) PRINT SPACE$(4); varname$; " ("; internalVarName$; ", line"; STR$(whichLine); ")" LOOP ELSE @@ -24946,12 +24946,11 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) IF INSTR(usedVariableList$, s$) = 0 THEN ASC(s$, 1) = 3 usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2) - usedVariableList$ = usedVariableList$ + s$ + name$ + CHR$(10) + usedVariableList$ = usedVariableList$ + "VAR:" + s$ + name$ + CHR$(10) totalUnusedVariables = totalUnusedVariables + 1 'warning$(1) = warning$(1) + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10) END IF CASE ELSE 'find and remove - s$ = CHR$(3) + MKI$(LEN(cname$)) + cname$ + CHR$(5) findItem = INSTR(usedVariableList$, s$) IF findItem THEN From 738c8d9bb5a4ef22b3bd205abad1ccb3e7151227 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 12 Jan 2019 21:09:31 -0200 Subject: [PATCH 09/10] Removes unused variables declared across qb64.bas and includes. --- source/ide/ide_global.bas | 10 ---------- source/ide/ide_methods.bas | 33 +-------------------------------- source/qb64.bas | 4 ++-- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index aaf1ae6c0..a5c7165fa 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -124,13 +124,6 @@ listOfKeywords$ = listOfKeywords$ + "_GLPOPATTRIB@_GLPOPCLIENTATTRIB@_GLPOPMATRI listOfKeywords$ = listOfKeywords$ + "_SOFTWARE@_SQUAREPIXELS@_STRETCH@_ALLOWFULLSCREEN@_ALL@_ECHO@_INSTRREV@_TRIM$@_ACCEPTFILEDROP@_FINISHDROP@_TOTALDROPPEDFILES@_DROPPEDFILE@_DROPPEDFILE$@_SHR@_SHL@" 'IDE MODULE: shared data & definitions -DIM SHARED mousex AS INTEGER -DIM SHARED mousey AS INTEGER -DIM SHARED mousewheel AS INTEGER -DIM SHARED mousebutton1 AS INTEGER -DIM SHARED mousebutton2 AS INTEGER -DIM SHARED mousevisible AS INTEGER -DIM SHARED mousepassed AS INTEGER '--------------------------------------------------- DIM SHARED idesubwindow, idehelp DIM SHARED ideexit @@ -222,6 +215,3 @@ DIM SHARED idewx, idewy, idecustomfont, idecustomfontfile$, idecustomfontheight, DIM SHARED iderunmode 'IDE MODULE SECTION END: shared data & definitions -DIM SHARED IdeAndroidMenu -DIM SHARED IdeAndroidStartScript AS STRING -DIM SHARED IdeAndroidMakeScript AS STRING diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 2983006e8..2d4de5908 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1040,7 +1040,7 @@ FUNCTION ide2 (ignore) END IF 'skipdisplay - STATIC prev_idecy AS LONG, idechangedbefore AS _BYTE + STATIC idechangedbefore AS _BYTE IF idechangemade THEN IF idelayoutallow THEN idelayoutallow = idelayoutallow - 1 @@ -5690,7 +5690,6 @@ FUNCTION idechange$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -5989,7 +5988,6 @@ SUB idechanged focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -6104,7 +6102,6 @@ FUNCTION idechangeit$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -6449,7 +6446,6 @@ SUB ideerrormessage (mess$) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -6564,7 +6560,6 @@ FUNCTION idefileexists$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -6685,7 +6680,6 @@ FUNCTION idefind$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7177,7 +7171,6 @@ SUB idenewsf (sf AS STRING) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7344,7 +7337,6 @@ SUB idenomatch focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7459,7 +7451,6 @@ FUNCTION ideopen$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7755,7 +7746,6 @@ FUNCTION iderestore$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7867,7 +7857,6 @@ FUNCTION ideclearhistory$ (WhichHistory$) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -7998,7 +7987,6 @@ FUNCTION idesaveas$ (programname$) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -8197,7 +8185,6 @@ FUNCTION idesavenow$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -8942,7 +8929,6 @@ FUNCTION idesubs$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -9315,7 +9301,6 @@ FUNCTION idelanguagebox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -10341,7 +10326,6 @@ FUNCTION idelayoutbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -10541,7 +10525,6 @@ FUNCTION idebackupbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -10708,7 +10691,6 @@ FUNCTION idemodifycommandbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -10844,7 +10826,6 @@ FUNCTION idegotobox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -11003,7 +10984,6 @@ FUNCTION ideadvancedbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -11193,7 +11173,6 @@ SUB idemessagebox (titlestr$, messagestr$) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -11328,7 +11307,6 @@ FUNCTION ideyesnobox$ (titlestr$, messagestr$) 'returns "Y" or "N" focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -11450,7 +11428,6 @@ FUNCTION idedisplaybox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -11781,7 +11758,6 @@ FUNCTION idechoosecolorsbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -12513,7 +12489,6 @@ FUNCTION idecolorpicker$ (editing) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -13198,7 +13173,6 @@ FUNCTION idesearchedbox$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -13418,7 +13392,6 @@ FUNCTION iderecentbox$ focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -13967,8 +13940,6 @@ SUB ideASCIIbox temp1 = _NEWIMAGE(640, 480, 32) ws = _NEWIMAGE(640, 480, 32) SCREEN temp - DIM CurrentASC(1 TO 16, 1 TO 16) - DIM CurrentOne AS INTEGER CLS , _RGB(0, 0, 170) COLOR , _RGB(0, 0, 170) FOR y = 1 TO 16 @@ -14104,7 +14075,6 @@ FUNCTION idef1box$ (lnks$, lnks) focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -14232,7 +14202,6 @@ SUB Mathbox focus = 1 DIM p AS idedbptype DIM o(1 TO 100) AS idedbotype - DIM oo AS idedbotype DIM sep AS STRING * 1 sep = CHR$(0) '-------- end of generic dialog box header -------- diff --git a/source/qb64.bas b/source/qb64.bas index 226e25713..df42d3050 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -8457,7 +8457,7 @@ DO IF n = 2 THEN IF firstelement$ = "GOSUB" THEN - xgosub ca$, n + xgosub ca$ IF Error_Happened THEN GOTO errmes 'note: layout implemented in xgosub GOTO finishedline @@ -22344,7 +22344,7 @@ SUB xfilewrite (ca$, n) layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ END SUB -SUB xgosub (ca$, n&) +SUB xgosub (ca$) a2$ = getelement(ca$, 2) IF validlabel(a2$) = 0 THEN Give_Error "Invalid label": EXIT SUB From 3902a36056c032854f639f3988bd97c1f5167e3a Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sun, 13 Jan 2019 03:26:48 -0200 Subject: [PATCH 10/10] New "Compilation status" dialog, for when there are warnings to show. + - Rewording of menu items; - New menu item in the View menu to show "Compilation status" dialog; --- source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 420 ++++++++++++++++++++++++++++--------- source/qb64.bas | 64 ++++-- 3 files changed, 369 insertions(+), 116 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index a5c7165fa..7ceb458f3 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -203,6 +203,7 @@ DIM SHARED OptionsMenuID AS INTEGER, OptionsMenuSwapMouse AS INTEGER, OptionsMen DIM SHARED OptionsMenuShowErrorsImmediately AS INTEGER DIM SHARED ViewMenuID AS INTEGER, ViewMenuShowLineNumbersSubMenuID AS INTEGER DIM SHARED ViewMenuShowSeparatorID AS INTEGER, ViewMenuShowBGID AS INTEGER +DIM SHARED ViewMenuCompilerWarnings AS INTEGER DIM SHARED RunMenuID AS INTEGER, RunMenuSaveExeWithSource AS INTEGER, brackethighlight AS INTEGER DIM SHARED multihighlight AS INTEGER, keywordHighlight AS INTEGER DIM SHARED PresetColorSchemes AS INTEGER, TotalColorSchemes AS INTEGER, ColorSchemes$(0) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 2d4de5908..59db0b077 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -252,7 +252,11 @@ FUNCTION ide2 (ignore) m = m + 1: i = 0: ViewMenuID = m menu$(m, i) = "View": i = i + 1 menu$(m, i) = "#SUBs... F2": i = i + 1 - menu$(m, i) = "#Line numbers " + CHR$(16): i = i + 1 + menu$(m, i) = "#Line Numbers " + CHR$(16): i = i + 1 + menu$(m, i) = "-": i = i + 1 + + ViewMenuCompilerWarnings = i + menu$(ViewMenuID, ViewMenuCompilerWarnings) = "Compiler #Warnings... Ctrl+W": i = i + 1 menusize(m) = i - 1 m = m + 1: i = 0: SearchMenuID = m @@ -261,11 +265,11 @@ FUNCTION ide2 (ignore) menu$(m, i) = "#Repeat Last Find (Shift+) F3": i = i + 1 menu$(m, i) = "#Change...": i = i + 1 menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "Clear search #history...": i = i + 1 + menu$(m, i) = "Clear Search #History...": i = i + 1 menu$(m, i) = "-": i = i + 1 SearchMenuEnableQuickNav = i - menu$(m, i) = "Enable #quick navigation (back arrow)": i = i + 1 + menu$(m, i) = "Enable #Quick Navigation (Back Arrow)": i = i + 1 IF EnableQuickNav THEN menu$(SearchMenuID, SearchMenuEnableQuickNav) = CHR$(7) + menu$(SearchMenuID, SearchMenuEnableQuickNav) END IF @@ -274,7 +278,7 @@ FUNCTION ide2 (ignore) menu$(m, i) = "#Next Bookmark Alt+Down": i = i + 1 menu$(m, i) = "#Previous Bookmark Alt+Up": i = i + 1 menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "#Go to line... Ctrl+G": i = i + 1 + menu$(m, i) = "#Go To Line... Ctrl+G": i = i + 1 menusize(m) = i - 1 @@ -285,7 +289,7 @@ FUNCTION ide2 (ignore) menu$(m, i) = "-": i = i + 1 RunMenuSaveExeWithSource = i - menu$(m, i) = "Output EXE to source #folder": i = i + 1 + menu$(m, i) = "Output EXE to Source #Folder": i = i + 1 IF SaveExeWithSource THEN menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + menu$(RunMenuID, RunMenuSaveExeWithSource) END IF @@ -305,7 +309,7 @@ FUNCTION ide2 (ignore) menu$(m, i) = "#Display...": i = i + 1 menu$(m, i) = "IDE C#olors...": i = i + 1 menu$(m, i) = "#Language...": i = i + 1 - menu$(m, i) = "#Code layout...": i = i + 1 + menu$(m, i) = "#Code Layout...": i = i + 1 menu$(m, i) = "#Backup/Undo...": i = i + 1 menu$(m, i) = "-": i = i + 1 menu$(m, i) = "#Advanced...": i = i + 1 @@ -317,13 +321,13 @@ FUNCTION ide2 (ignore) END IF OptionsMenuPasteCursor = i - menu$(m, i) = "Cursor after #pasted content": i = i + 1 + menu$(m, i) = "Cursor After #Pasted Content": i = i + 1 IF PasteCursorAtEnd THEN menu$(OptionsMenuID, OptionsMenuPasteCursor) = CHR$(7) + menu$(OptionsMenuID, OptionsMenuPasteCursor) END IF OptionsMenuShowErrorsImmediately = i - menu$(m, i) = "Show compilation #errors immediately": i = i + 1 + menu$(m, i) = "Show Compilation #Errors Immediately": i = i + 1 IF IDEShowErrorsImmediately THEN menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = CHR$(7) + menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) END IF @@ -333,14 +337,14 @@ FUNCTION ide2 (ignore) m = m + 1: i = 0 menu$(m, i) = "Help": i = i + 1 menu$(m, i) = "#View Shift+F1": i = i + 1 - menu$(m, i) = "#Contents page": i = i + 1 - menu$(m, i) = "Keyword #index": i = i + 1 - menu$(m, i) = "#Keywords by usage": i = i + 1 - menu$(m, i) = "ASCII c#hart": i = i + 1 + menu$(m, i) = "#Contents Page": i = i + 1 + menu$(m, i) = "Keyword #Index": i = i + 1 + menu$(m, i) = "#Keywords by Usage": i = i + 1 + menu$(m, i) = "ASCII C#hart": i = i + 1 menu$(m, i) = "#Math": i = i + 1 menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "#Update current page": i = i + 1 - menu$(m, i) = "Update all #pages": i = i + 1 + menu$(m, i) = "#Update Current Page": i = i + 1 + menu$(m, i) = "Update All #Pages": i = i + 1 menu$(m, i) = "-": i = i + 1 menu$(m, i) = "#About...": i = i + 1 menusize(m) = i - 1 @@ -355,13 +359,13 @@ FUNCTION ide2 (ignore) m = m + 1: i = 0 menu$(m, i) = "ViewMenuShowLineNumbersSubMenu": i = i + 1 ViewMenuShowLineNumbersSubMenuID = m - IF ShowLineNumbers THEN menu$(m, i) = "#Hide line numbers" ELSE menu$(m, i) = "#Show line numbers" + IF ShowLineNumbers THEN menu$(m, i) = "#Hide Line Numbers" ELSE menu$(m, i) = "#Show Line Numbers" i = i + 1 - menu$(m, i) = "#Background color": IF ShowLineNumbersUseBG THEN menu$(m, i) = CHR$(7) + menu$(m, i) + menu$(m, i) = "#Background Color": IF ShowLineNumbersUseBG THEN menu$(m, i) = CHR$(7) + menu$(m, i) ViewMenuShowBGID = i IF ShowLineNumbers = 0 THEN menu$(m, i) = "~" + menu$(m, i) i = i + 1 - menu$(m, i) = "Sho#w separator": IF ShowLineNumbersSeparator THEN menu$(m, i) = CHR$(7) + menu$(m, i) + menu$(m, i) = "Sho#w Separator": IF ShowLineNumbersSeparator THEN menu$(m, i) = CHR$(7) + menu$(m, i) ViewMenuShowSeparatorID = i IF ShowLineNumbers = 0 THEN menu$(m, i) = "~" + menu$(m, i) i = i + 1 @@ -639,6 +643,12 @@ FUNCTION ide2 (ignore) COLOR 7, 1: LOCATE idewy - 3, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 2, 2: PRINT SPACE$(idewx - 2);: LOCATE idewy - 1, 2: PRINT SPACE$(idewx - 2); 'clear status window IF ready THEN IF IDEShowErrorsImmediately THEN LOCATE idewy - 3, 2: PRINT "OK"; 'report OK status + IF totalWarnings > 0 THEN + COLOR 11, 1 + PRINT " ("; LTRIM$(STR$(totalWarnings)) + " warning"; + IF totalWarnings > 1 THEN PRINT "s"; + PRINT " - click here or Ctrl+W to view)"; + END IF END IF IF showexecreated THEN showexecreated = 0 @@ -1405,14 +1415,24 @@ FUNCTION ide2 (ignore) END IF '3- Link to the output folder when "Output EXE to source #folder" is checked: - IF INSTR(_OS$, "WIN") THEN - SHELL _DONTWAIT "explorer /select," + QuotedFilename$(path.exe$ + file$ + extension$) - ELSEIF INSTR(_OS$, "MAC") THEN - SHELL _DONTWAIT "open " + QuotedFilename$(path.exe$) - ELSE - SHELL _DONTWAIT "xdg-open " + QuotedFilename$(path.exe$) + IF showexecreated THEN + IF INSTR(_OS$, "WIN") THEN + SHELL _DONTWAIT "explorer /select," + QuotedFilename$(path.exe$ + file$ + extension$) + ELSEIF INSTR(_OS$, "MAC") THEN + SHELL _DONTWAIT "open " + QuotedFilename$(path.exe$) + ELSE + SHELL _DONTWAIT "xdg-open " + QuotedFilename$(path.exe$) + END IF + GOTO specialchar + END IF + + '4- Link to Warnings dialog: + IF totalWarnings > 0 THEN + retval = idewarningbox + 'retval is ignored + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO specialchar END IF - GOTO specialchar END IF END IF END IF @@ -2725,6 +2745,12 @@ FUNCTION ide2 (ignore) PRINT "..."; ELSE PRINT "OK"; 'report OK status + IF totalWarnings > 0 THEN + COLOR 11, 1 + PRINT " ("; LTRIM$(STR$(totalWarnings)) + " warning"; + IF totalWarnings > 1 THEN PRINT "s"; + PRINT " - click here or Ctrl+W to view)"; + END IF END IF END IF ELSE @@ -3044,6 +3070,19 @@ FUNCTION ide2 (ignore) GOTO idesubsjmp END IF + IF KCONTROL AND UCASE$(K$) = "W" THEN 'goto line + IF totalWarnings > 0 THEN + retval = idewarningbox + 'retval is ignored + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO specialchar + ELSE + idemessagebox "Compilation status", "No warnings to display." + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + END IF + IF KCONTROL AND UCASE$(K$) = "Z" THEN 'undo (CTRL+Z) idemundo: IF ideundopos THEN @@ -4101,6 +4140,13 @@ FUNCTION ide2 (ignore) IF idecontextualmenu = 1 THEN idectxmenuX = mX: idectxmenuY = mY: m = idecontextualmenuID IF idecontextualmenu = 2 THEN idectxmenuX = xx + w + 3: idectxmenuY = yy + r: parentMenu = m: m = ViewMenuShowLineNumbersSubMenuID IdeMakeEditMenu + + IF totalWarnings = 0 THEN + menu$(ViewMenuID, ViewMenuCompilerWarnings) = "~Compiler #Warnings... Ctrl+W" + ELSE + menu$(ViewMenuID, ViewMenuCompilerWarnings) = "Compiler #Warnings... Ctrl+W" + END IF + oldmy = mY: oldmx = mX DO PCOPY 2, 1 @@ -4357,7 +4403,7 @@ FUNCTION ide2 (ignore) IF KB = KEY_RIGHT AND idecontextualmenu = 0 THEN IF RIGHT$(menu$(m, r), 1) = CHR$(16) THEN SELECT CASE LEFT$(menu$(m, r), LEN(menu$(m, r)) - 3) - CASE "#Line numbers" + CASE "#Line Numbers" idecontextualmenu = 2 GOTO showmenu END SELECT @@ -4419,7 +4465,7 @@ FUNCTION ide2 (ignore) menuChoiceMade: IF KALT THEN idehl = 1 ELSE idehl = 0 'set idehl, a shared variable used by various dialogue boxes - IF menu$(m, s) = "Add comment (') Ctrl+R" THEN + IF menu$(m, s) = "Add Comment (') Ctrl+R" THEN ctrlAddComment: y1 = idecy: y2 = y1 IF ideselect = 1 THEN @@ -4450,7 +4496,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Remove comment (') Ctrl+Shift+R" THEN + IF menu$(m, s) = "Remove Comment (') Ctrl+Shift+R" THEN ctrlRemoveComment: PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt y1 = idecy: y2 = y1 @@ -4477,7 +4523,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Toggle comment Ctrl+T" THEN + IF menu$(m, s) = "Toggle Comment Ctrl+T" THEN ctrlToggleComment: PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt y1 = idecy: y2 = y1 @@ -4518,13 +4564,13 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Increase indent TAB" THEN + IF menu$(m, s) = "Increase Indent TAB" THEN IF ideselect THEN GOTO IdeBlockIncreaseIndent PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF LEFT$(menu$(m, s), 15) = "Decrease indent" THEN + IF LEFT$(menu$(m, s), 15) = "Decrease Indent" THEN IF ideselect THEN GOTO IdeBlockDecreaseIndent PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop @@ -4565,7 +4611,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Open _RGB color mi#xer" THEN + IF menu$(m, s) = "Open _RGB Color Mi#xer" THEN PCOPY 2, 0 oldkeywordHighlight = keywordHighlight keywordHighlight = 0 @@ -4599,64 +4645,64 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 28) = "Cursor after #pasted content" THEN + IF RIGHT$(menu$(m, s), 28) = "Cursor After #Pasted Content" THEN PCOPY 2, 0 PasteCursorAtEnd = NOT PasteCursorAtEnd IF PasteCursorAtEnd THEN WriteConfigSetting "'[GENERAL SETTINGS]", "PasteCursorAtEnd", "TRUE" - menu$(OptionsMenuID, OptionsMenuPasteCursor) = CHR$(7) + "Cursor after #pasted content" + menu$(OptionsMenuID, OptionsMenuPasteCursor) = CHR$(7) + "Cursor After #Pasted Content" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "PasteCursorAtEnd", "FALSE" - menu$(OptionsMenuID, OptionsMenuPasteCursor) = "Cursor after #pasted content" + menu$(OptionsMenuID, OptionsMenuPasteCursor) = "Cursor After #Pasted Content" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 36) = "Show compilation #errors immediately" THEN + IF RIGHT$(menu$(m, s), 36) = "Show Compilation #Errors Immediately" THEN PCOPY 2, 0 IDEShowErrorsImmediately = NOT IDEShowErrorsImmediately IF IDEShowErrorsImmediately THEN WriteConfigSetting "'[GENERAL SETTINGS]", "ShowErrorsImmediately", "TRUE" - menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = CHR$(7) + "Show compilation #errors immediately" + menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = CHR$(7) + "Show Compilation #Errors Immediately" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "ShowErrorsImmediately", "FALSE" - menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = "Show compilation #errors immediately" + menu$(OptionsMenuID, OptionsMenuShowErrorsImmediately) = "Show Compilation #Errors Immediately" END IF idechangemade = 1 PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 28) = "Output EXE to source #folder" THEN + IF RIGHT$(menu$(m, s), 28) = "Output EXE to Source #Folder" THEN PCOPY 2, 0 SaveExeWithSource = NOT SaveExeWithSource IF SaveExeWithSource THEN WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "TRUE" - menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Output EXE to source #folder" + menu$(RunMenuID, RunMenuSaveExeWithSource) = CHR$(7) + "Output EXE to Source #Folder" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "SaveExeWithSource", "FALSE" - menu$(RunMenuID, RunMenuSaveExeWithSource) = "Output EXE to source #folder" + menu$(RunMenuID, RunMenuSaveExeWithSource) = "Output EXE to Source #Folder" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF MID$(menu$(m, s), 1, 24) = "Enable #quick navigation" OR MID$(menu$(m, s), 2, 24) = "Enable #quick navigation" THEN + IF MID$(menu$(m, s), 1, 24) = "Enable #Quick Navigation" OR MID$(menu$(m, s), 2, 24) = "Enable #Quick Navigation" THEN PCOPY 2, 0 EnableQuickNav = NOT EnableQuickNav IF EnableQuickNav THEN WriteConfigSetting "'[GENERAL SETTINGS]", "EnableQuickNav", "TRUE" - menu$(SearchMenuID, SearchMenuEnableQuickNav) = CHR$(7) + "Enable #quick navigation (back arrow)" + menu$(SearchMenuID, SearchMenuEnableQuickNav) = CHR$(7) + "Enable #Quick Navigation (Back Arrow)" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "EnableQuickNav", "FALSE" - menu$(SearchMenuID, SearchMenuEnableQuickNav) = "Enable #quick navigation (back arrow)" + menu$(SearchMenuID, SearchMenuEnableQuickNav) = "Enable #Quick Navigation (Back Arrow)" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF menu$(m, s) = "#Code layout..." THEN + IF menu$(m, s) = "#Code Layout..." THEN PCOPY 2, 0 retval = idelayoutbox IF retval THEN idechangemade = 1: idelayoutallow = 2 'recompile if options changed @@ -4727,7 +4773,7 @@ FUNCTION ide2 (ignore) - IF menu$(m, s) = "#Go to line... Ctrl+G" THEN + IF menu$(m, s) = "#Go To Line... Ctrl+G" THEN PCOPY 2, 0 retval = idegotobox 'retval is ignored @@ -4751,7 +4797,7 @@ FUNCTION ide2 (ignore) END IF - IF menu$(m, s) = "ASCII c#hart" THEN + IF menu$(m, s) = "ASCII C#hart" THEN PCOPY 2, 0 ideASCIIbox PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt @@ -4760,12 +4806,12 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF LEFT$(menu$(m, s), 10) = "#Help on '" THEN 'Contextual menu Help + IF LEFT$(menu$(m, s), 10) = "#Help On '" THEN 'Contextual menu Help PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO contextualhelp END IF - IF LEFT$(menu$(m, s), 10) = "#Go to SUB" OR LEFT$(menu$(m, s), 15) = "#Go to FUNCTION" THEN 'Contextual menu Goto + IF LEFT$(menu$(m, s), 10) = "#Go To SUB" OR LEFT$(menu$(m, s), 15) = "#Go To FUNCTION" THEN 'Contextual menu Goto PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt AddQuickNavHistory idecy idecy = CVL(MID$(SubFuncLIST(1), 1, 4)) @@ -4776,7 +4822,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF LEFT$(menu$(m, s), 12) = "Go to #label" THEN 'Contextual menu Goto label + IF LEFT$(menu$(m, s), 12) = "Go To #Label" THEN 'Contextual menu Goto label PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt AddQuickNavHistory idecy idecy = CVL(MID$(SubFuncLIST(UBOUND(SubFuncLIST)), 1, 4)) @@ -4787,17 +4833,17 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "#Contents page" THEN + IF menu$(m, s) = "#Contents Page" THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt lnk$ = "QB64 Help Menu" GOTO OpenHelpLnk END IF - IF menu$(m, s) = "Keyword #index" THEN + IF menu$(m, s) = "Keyword #Index" THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt lnk$ = "Keyword Reference - Alphabetical" GOTO OpenHelpLnk END IF - IF menu$(m, s) = "#Keywords by usage" THEN + IF menu$(m, s) = "#Keywords by Usage" THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt lnk$ = "Keyword Reference - By usage" GOTO OpenHelpLnk @@ -4818,7 +4864,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "#Update current page" THEN + IF menu$(m, s) = "#Update Current Page" THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt IF idehelp THEN Help_IgnoreCache = 1 @@ -4836,7 +4882,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Update all #pages" THEN + IF menu$(m, s) = "Update All #Pages" THEN PCOPY 2, 0 q$ = ideyesnobox("Update Help", "Redownload all cached help content? (~10 min)") PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt @@ -4959,65 +5005,73 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "#Line numbers " + CHR$(16) THEN + IF menu$(m, s) = "#Line Numbers " + CHR$(16) THEN idecontextualmenu = 2 GOTO showmenu END IF - IF menu$(m, s) = "#Show line numbers" THEN + IF menu$(m, s) = "#Show Line Numbers" THEN PCOPY 2, 0 ShowLineNumbers = -1 WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "TRUE" - menu$(m, s) = "#Hide line numbers" + menu$(m, s) = "#Hide Line Numbers" menu$(m, ViewMenuShowBGID) = MID$(menu$(m, ViewMenuShowBGID), 2) menu$(m, ViewMenuShowSeparatorID) = MID$(menu$(m, ViewMenuShowSeparatorID), 2) PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF menu$(m, s) = "#Hide line numbers" THEN + IF menu$(m, s) = "#Hide Line Numbers" THEN PCOPY 2, 0 ShowLineNumbers = 0 WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbers", "FALSE" - menu$(m, s) = "#Show line numbers" + menu$(m, s) = "#Show Line Numbers" menu$(m, ViewMenuShowBGID) = "~" + menu$(m, ViewMenuShowBGID) menu$(m, ViewMenuShowSeparatorID) = "~" + menu$(m, ViewMenuShowSeparatorID) PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF - IF RIGHT$(menu$(m, s), 17) = "#Background color" THEN + IF RIGHT$(menu$(m, s), 17) = "#Background Color" THEN IF LEFT$(menu$(m, s), 1) <> "~" THEN PCOPY 2, 0 ShowLineNumbersUseBG = NOT ShowLineNumbersUseBG IF ShowLineNumbersUseBG THEN WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "TRUE" - menu$(m, s) = CHR$(7) + "#Background color" + menu$(m, s) = CHR$(7) + "#Background Color" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersUseBG", "FALSE" - menu$(m, s) = "#Background color" + menu$(m, s) = "#Background Color" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF END IF - IF RIGHT$(menu$(m, s), 15) = "Sho#w separator" THEN + IF RIGHT$(menu$(m, s), 15) = "Sho#w Separator" THEN IF LEFT$(menu$(m, s), 1) <> "~" THEN PCOPY 2, 0 ShowLineNumbersSeparator = NOT ShowLineNumbersSeparator IF ShowLineNumbersSeparator THEN WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "TRUE" - menu$(m, s) = CHR$(7) + "Sho#w separator" + menu$(m, s) = CHR$(7) + "Sho#w Separator" ELSE WriteConfigSetting "'[GENERAL SETTINGS]", "ShowLineNumbersSeparator", "FALSE" - menu$(m, s) = "Sho#w separator" + menu$(m, s) = "Sho#w Separator" END IF PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt GOTO ideloop END IF END IF + IF menu$(m, s) = "Compiler #Warnings... Ctrl+W" THEN + PCOPY 2, 0 + retval = idewarningbox + 'retval is ignored + PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt + GOTO ideloop + END IF + IF menu$(m, s) = "#Find... Ctrl+F3" THEN PCOPY 2, 0 idefindjmp: @@ -5180,7 +5234,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF '#Change... - IF menu$(m, s) = "Clear search #history..." THEN + IF menu$(m, s) = "Clear Search #History..." THEN PCOPY 2, 0 r$ = ideclearhistory$("SEARCH") IF r$ = "Y" THEN @@ -5242,8 +5296,6 @@ FUNCTION ide2 (ignore) GOTO idemselectall END IF - menu$(m, i) = "Select #All Ctrl+A": i = i + 1 - IF menu$(m, s) = "#Start F5" THEN PCOPY 3, 0: SCREEN , , 3, 0: idewait4mous: idewait4alt UseAndroid 0 @@ -5386,7 +5438,7 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Clear #recent..." THEN + IF menu$(m, s) = "Clear #Recent..." THEN PCOPY 2, 0 r$ = ideclearhistory$("FILES") IF r$ = "Y" THEN @@ -5638,6 +5690,12 @@ FUNCTION ide2 (ignore) PRINT "..."; ELSE PRINT "OK"; 'report OK status + IF totalWarnings > 0 THEN + COLOR 11, 1 + PRINT " ("; LTRIM$(STR$(totalWarnings)) + " warning"; + IF totalWarnings > 1 THEN PRINT "s"; + PRINT " - click here or Ctrl+W to view)"; + END IF END IF END IF RETURN @@ -8496,13 +8554,13 @@ SUB ideshowtext END IF IF l <= iden THEN - IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + CHR$(3)) > 0 THEN - LOCATE y + 3, 1 - prevBG% = _BACKGROUNDCOLOR - COLOR 13, 1 - PRINT CHR$(26); 'indicate there's an unused variable defined on this line - COLOR , prevBG% - END IF + 'IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + "VAR:" + CHR$(3)) > 0 THEN + ' LOCATE y + 3, 1 + ' prevBG% = _BACKGROUNDCOLOR + ' COLOR 15, 7 + ' PRINT CHR$(26); 'indicate there's an unused variable defined on this line + ' COLOR , prevBG% + 'END IF a$ = idegetline(l) link_idecx = 0 @@ -8884,9 +8942,9 @@ SUB ideshowtext FOR b = 1 TO IdeBmkN y = IdeBmk(b).y IF y >= idesy AND y <= idesy + (idewy - 9) THEN - IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + CHR$(3)) = 0 THEN - LOCATE 3 + y - idesy, 1: PRINT CHR$(197); - END IF + 'IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + "VAR:" + CHR$(3)) = 0 THEN + LOCATE 3 + y - idesy, 1: PRINT CHR$(197); + 'END IF END IF NEXT @@ -9438,6 +9496,164 @@ FUNCTION idelanguagebox +END FUNCTION + +FUNCTION idewarningbox + + '-------- generic dialog box header -------- + PCOPY 0, 2 + PCOPY 0, 1 + SCREEN , , 1, 0 + focus = 1 + DIM p AS idedbptype + DIM o(1 TO 100) AS idedbotype + DIM sep AS STRING * 1 + sep = CHR$(0) + '-------- end of generic dialog box header -------- + + '-------- init -------- + + DIM warningLines(1 TO warningListItems) AS LONG + + FOR x = 1 TO warningListItems + warningLines(x) = CVL(LEFT$(warning$(x), 4)) + IF warningLines(x) = 0 THEN + l$ = l$ + MID$(warning$(x), 5) + IF x > 1 THEN ASC(l$, treeConnection) = 192 + ELSE + l2$ = "line" + STR$(warningLines(x)) + l3$ = SPACE$(maxLineNumberLength + 4) + RSET l3$ = l2$ + treeConnection = LEN(l$) + 1 + l$ = l$ + CHR$(195) + CHR$(196) + l3$ + ": " + MID$(warning$(x), 5) + END IF + IF x < warningListItems THEN l$ = l$ + sep + NEXT + + IF warningLines(warningListItems) > 0 THEN + ASC(l$, treeConnection) = 192 + END IF + + i = 0 + dialogHeight = warningListItems + 4 + IF dialogHeight > idewy + idesubwindow - 6 THEN + dialogHeight = idewy + idesubwindow - 6 + END IF + + idepar p, idewx - 8, dialogHeight, "Compilation status" + + i = i + 1 + o(i).typ = 2 + o(i).y = 2 + o(i).w = idewx - 12: o(i).h = dialogHeight - 4 + o(i).txt = idenewtxt(l$) + o(i).sel = 1: IF idecpindex THEN o(i).sel = idecpindex + o(i).nam = idenewtxt("Warnings (" + LTRIM$(STR$(totalWarnings)) + ")") + + i = i + 1 + o(i).typ = 3 + o(i).y = dialogHeight + o(i).txt = idenewtxt("#Go to" + sep + "#Close") + o(i).dft = 1 + + + + + + '-------- end of init -------- + + '-------- generic init -------- + FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects + '-------- end of generic init -------- + + DO 'main loop + + '-------- generic display dialog box & objects -------- + idedrawpar p + f = 1: cx = 0: cy = 0 + FOR i = 1 TO 100 + IF o(i).typ THEN + 'prepare object + o(i).foc = focus - f 'focus offset + o(i).cx = 0: o(i).cy = 0 + idedrawobj o(i), f 'display object + IF o(i).cx THEN cx = o(i).cx: cy = o(i).cy + END IF + NEXT i + lastfocus = f - 1 + '-------- end of generic display dialog box & objects -------- + + '-------- custom display changes -------- + COLOR 0, 7: LOCATE p.y + 1, p.x + 2: PRINT "Double-click on an item to jump to the line indicated" + + '-------- end of custom display changes -------- + + 'update visual page and cursor position + PCOPY 1, 0 + IF cx THEN SCREEN , , 0, 0: LOCATE cy, cx, 1: SCREEN , , 1, 0 + + '-------- read input -------- + change = 0 + DO + GetInput + IF mWHEEL THEN change = 1 + IF KB THEN change = 1 + IF mCLICK THEN mousedown = 1: change = 1 + IF mRELEASE THEN mouseup = 1: change = 1 + IF mB THEN change = 1 + alt = KALT: IF alt <> oldalt THEN change = 1 + oldalt = alt + _LIMIT 100 + LOOP UNTIL change + IF alt AND NOT KCTRL THEN idehl = 1 ELSE idehl = 0 + 'convert "alt+letter" scancode to letter's ASCII character + altletter$ = "" + IF alt AND NOT KCTRL THEN + IF LEN(K$) = 1 THEN + k = ASC(UCASE$(K$)) + IF k >= 65 AND k <= 90 THEN altletter$ = CHR$(k) + END IF + END IF + SCREEN , , 0, 0: LOCATE , , 0: SCREEN , , 1, 0 + '-------- end of read input -------- + + '-------- generic input response -------- + info = 0 + IF K$ = "" THEN K$ = CHR$(255) + IF KSHIFT = 0 AND K$ = CHR$(9) THEN focus = focus + 1 + IF (KSHIFT AND K$ = CHR$(9)) OR (INSTR(_OS$, "MAC") AND K$ = CHR$(25)) THEN focus = focus - 1: K$ = "" + IF focus < 1 THEN focus = lastfocus + IF focus > lastfocus THEN focus = 1 + f = 1 + FOR i = 1 TO 100 + t = o(i).typ + IF t THEN + focusoffset = focus - f + ideobjupdate o(i), focus, f, focusoffset, K$, altletter$, mB, mousedown, mouseup, mX, mY, info, mWHEEL + END IF + NEXT + '-------- end of generic input response -------- + + IF K$ = CHR$(27) OR (focus = 3 AND info <> 0) THEN + EXIT FUNCTION + END IF + + IF K$ = CHR$(13) OR (focus = 2 AND info <> 0) OR (info = 1 AND focus = 1) THEN + y = ABS(o(1).sel) + IF y >= 1 AND y <= warningListItems AND warningLines(y) > 0 THEN + idegotobox_LastLineNum = warningLines(y) + AddQuickNavHistory idecy + idecy = idegotobox_LastLineNum + ideselect = 0 + EXIT FUNCTION + END IF + END IF + + 'end of custom controls + mousedown = 0 + mouseup = 0 + LOOP + END FUNCTION SUB ideobjupdate (o AS idedbotype, focus, f, focusoffset, kk$, altletter$, mb, mousedown, mouseup, mx, my, info, mw) @@ -13565,7 +13781,7 @@ SUB IdeMakeFileMenu NEXT CLOSE #fh IF menu$(m, i - 1) <> "#Recent..." AND menu$(m, i - 1) <> "Save #As..." THEN - menu$(m, i) = "Clear #recent...": i = i + 1 + menu$(m, i) = "Clear #Recent...": i = i + 1 END IF menu$(m, i) = "-": i = i + 1 menu$(m, i) = "E#xit": i = i + 1 @@ -13708,7 +13924,7 @@ SUB IdeMakeContextualMenu IF UCASE$(CursorSF$) = CurrSF$ THEN EXIT FOR ELSE - menu$(m, i) = "#Go to " + CursorSF$: i = i + 1 + menu$(m, i) = "#Go To " + CursorSF$: i = i + 1 SubFuncLIST(1) = SubFuncLIST(CheckSF) EXIT FOR END IF @@ -13727,7 +13943,7 @@ SUB IdeMakeContextualMenu GOTO CheckThisLabel END IF IF LabelLineNumber > 0 AND LabelLineNumber <> idecy THEN - menu$(m, i) = "Go to #label " + RTRIM$(Labels(r).cn): i = i + 1 + menu$(m, i) = "Go To #Label " + RTRIM$(Labels(r).cn): i = i + 1 REDIM _PRESERVE SubFuncLIST(1 TO UBOUND(SubFuncLIST) + 1) AS STRING SubFuncLIST(UBOUND(SubFuncLIST)) = MKL$(Labels(r).SourceLineNumber) END IF @@ -13756,7 +13972,7 @@ SUB IdeMakeContextualMenu l2$ = LEFT$(l2$, 12) + STRING$(3, 250) END IF IF INSTR(l2$, "Parenthesis") = 0 THEN - menu$(m, i) = "#Help on '" + l2$ + "'": i = i + 1 + menu$(m, i) = "#Help On '" + l2$ + "'": i = i + 1 END IF END IF END IF @@ -13777,7 +13993,7 @@ SUB IdeMakeContextualMenu Found_RGB = Found_RGB + INSTR(UCASE$(a$), "_RGBA(") Found_RGB = Found_RGB + INSTR(UCASE$(a$), "_RGBA32(") IF Found_RGB THEN - menu$(m, i) = "Open _RGB color mi#xer": i = i + 1 + menu$(m, i) = "Open _RGB Color Mi#xer": i = i + 1 menu$(m, i) = "-": i = i + 1 END IF NoRGBFound: @@ -13792,9 +14008,9 @@ SUB IdeMakeContextualMenu IF ideselect THEN menu$(m, i) = "Cl#ear Del": i = i + 1 menu$(m, i) = "Select #All Ctrl+A": i = i + 1 menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "Toggle comment Ctrl+T": i = i + 1 - menu$(m, i) = "Add comment (') Ctrl+R": i = i + 1 - menu$(m, i) = "Remove comment (') Ctrl+Shift+R": i = i + 1 + menu$(m, i) = "Toggle Comment Ctrl+T": i = i + 1 + menu$(m, i) = "Add Comment (') Ctrl+R": i = i + 1 + menu$(m, i) = "Remove Comment (') Ctrl+Shift+R": i = i + 1 IF ideselect THEN y1 = idecy y2 = ideselecty1 @@ -13807,15 +14023,15 @@ SUB IdeMakeContextualMenu IF x <= LEN(a$) THEN a2$ = a2$ + MID$(a$, x, 1) ELSE a2$ = a2$ + " " NEXT IF a2$ <> "" THEN - menu$(m, i) = "Increase indent TAB": i = i + 1 - menu$(m, i) = "Decrease indent" + menu$(m, i) = "Increase Indent TAB": i = i + 1 + menu$(m, i) = "Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 menu$(m, i) = "-": i = i + 1 END IF ELSE - menu$(m, i) = "Increase indent TAB": i = i + 1 - menu$(m, i) = "Decrease indent" + menu$(m, i) = "Increase Indent TAB": i = i + 1 + menu$(m, i) = "Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 menu$(m, i) = "-": i = i + 1 @@ -13859,9 +14075,9 @@ SUB IdeMakeEditMenu menu$(m, i) = "Select #All Ctrl+A": i = i + 1 menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "Toggle comment Ctrl+T": i = i + 1 - menu$(m, i) = "Add comment (') Ctrl+R": i = i + 1 - menu$(m, i) = "Remove comment (') Ctrl+Shift+R": i = i + 1 + menu$(m, i) = "Toggle Comment Ctrl+T": i = i + 1 + menu$(m, i) = "Add Comment (') Ctrl+R": i = i + 1 + menu$(m, i) = "Remove Comment (') Ctrl+Shift+R": i = i + 1 IF ideselect THEN y1 = idecy y2 = ideselecty1 @@ -13874,25 +14090,25 @@ SUB IdeMakeEditMenu IF x <= LEN(a$) THEN a2$ = a2$ + MID$(a$, x, 1) ELSE a2$ = a2$ + " " NEXT IF a2$ = "" THEN - menu$(m, i) = "~Increase indent TAB": i = i + 1 - menu$(m, i) = "~Decrease indent" + menu$(m, i) = "~Increase Indent TAB": i = i + 1 + menu$(m, i) = "~Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 ELSE - menu$(m, i) = "Increase indent TAB": i = i + 1 - menu$(m, i) = "Decrease indent" + menu$(m, i) = "Increase Indent TAB": i = i + 1 + menu$(m, i) = "Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 END IF ELSE - menu$(m, i) = "Increase indent TAB": i = i + 1 - menu$(m, i) = "Decrease indent" + menu$(m, i) = "Increase Indent TAB": i = i + 1 + menu$(m, i) = "Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 END IF ELSE - menu$(m, i) = "~Increase indent TAB": i = i + 1 - menu$(m, i) = "~Decrease indent" + menu$(m, i) = "~Increase Indent TAB": i = i + 1 + menu$(m, i) = "~Decrease Indent" IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" i = i + 1 END IF diff --git a/source/qb64.bas b/source/qb64.bas index df42d3050..f117940cf 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -112,7 +112,7 @@ DIM SHARED ConsoleMode, No_C_Compile_Mode, Cloud, NoIDEMode DIM SHARED VerboseMode AS _BYTE, CMDLineFile AS STRING DIM SHARED totalUnusedVariables AS LONG, usedVariableList$, bypassNextVariable AS _BYTE -DIM SHARED totalWarnings AS LONG +DIM SHARED totalWarnings AS LONG, warningListItems AS LONG DIM SHARED ExeIconSet AS LONG DIM SHARED VersionInfoSet AS _BYTE @@ -1434,7 +1434,8 @@ UserDefineCount = 6 usedVariableList$ = "" totalUnusedVariables = 0 totalWarnings = 0 -REDIM SHARED warning$(100) +warningListItems = 0 +REDIM SHARED warning$(1000) uniquenumbern = 0 ''create a type for storing memory blocks @@ -11638,16 +11639,43 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log 'PUT #1, 1, usedVariableList$ 'warning$(1) 'CLOSE #1 -IF idemode THEN GOTO ideret5 -ide6: - - -IF totalUnusedVariables > 0 AND idemode = 0 THEN - PRINT - PRINT "WARNING:"; STR$(totalUnusedVariables); " UNUSED VARIABLES"; - IF VerboseMode THEN - PRINT ":" +IF totalUnusedVariables > 0 THEN + IF idemode = 0 THEN + PRINT + PRINT "WARNING:"; STR$(totalUnusedVariables); " UNUSED VARIABLES"; + IF VerboseMode THEN + PRINT ":" + findItem = 0 + DO + s$ = CHR$(2) + "VAR:" + CHR$(3) + findItem = INSTR(findItem + 1, usedVariableList$, s$) + IF findItem = 0 THEN EXIT DO + whichLine = CVL(MID$(usedVariableList$, findItem - 4, 4)) + varNameLen = CVI(MID$(usedVariableList$, findItem + 6, 2)) + internalVarName$ = MID$(usedVariableList$, findItem + 8, varNameLen) + findLF = INSTR(findItem + 9 + varNameLen, usedVariableList$, CHR$(10)) + varname$ = MID$(usedVariableList$, findItem + 9 + varNameLen, findLF - (findItem + 9 + varNameLen)) + PRINT SPACE$(4); varname$; " ("; internalVarName$; ", line"; STR$(whichLine); ")" + LOOP + ELSE + PRINT + END IF + ELSE findItem = 0 + maxVarNameLen = 0 + DO + s$ = CHR$(2) + "VAR:" + CHR$(3) + findItem = INSTR(findItem + 1, usedVariableList$, s$) + IF findItem = 0 THEN EXIT DO + varNameLen = CVI(MID$(usedVariableList$, findItem + 6, 2)) + internalVarName$ = MID$(usedVariableList$, findItem + 8, varNameLen) + findLF = INSTR(findItem + 9 + varNameLen, usedVariableList$, CHR$(10)) + varname$ = MID$(usedVariableList$, findItem + 9 + varNameLen, findLF - (findItem + 9 + varNameLen)) + IF LEN(varname$) > maxVarNameLen THEN maxVarNameLen = LEN(varname$) + LOOP + + findItem = 0 + addWarning 0, "Unused variables (" + LTRIM$(STR$(totalUnusedVariables)) + "):" DO s$ = CHR$(2) + "VAR:" + CHR$(3) findItem = INSTR(findItem + 1, usedVariableList$, s$) @@ -11657,13 +11685,13 @@ IF totalUnusedVariables > 0 AND idemode = 0 THEN internalVarName$ = MID$(usedVariableList$, findItem + 8, varNameLen) findLF = INSTR(findItem + 9 + varNameLen, usedVariableList$, CHR$(10)) varname$ = MID$(usedVariableList$, findItem + 9 + varNameLen, findLF - (findItem + 9 + varNameLen)) - PRINT SPACE$(4); varname$; " ("; internalVarName$; ", line"; STR$(whichLine); ")" + addWarning whichLine, varname$ + SPACE$((maxVarNameLen + 1) - LEN(varname$)) + " (" + internalVarName$ + ")" LOOP - ELSE - PRINT END IF END IF +IF idemode THEN GOTO ideret5 +ide6: IF idemode = 0 AND No_C_Compile_Mode = 0 THEN PRINT @@ -24961,6 +24989,14 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) END SELECT END SUB +SUB addWarning (lineNumber AS LONG, text$) + warningListItems = warningListItems + 1 + IF warningListItems > UBOUND(warning$) THEN REDIM _PRESERVE warning$(warningListItems + 999) + + warning$(warningListItems) = MKL$(lineNumber) + text$ + IF lineNumber > 0 THEN totalWarnings = totalWarnings + 1 +END SUB + '$INCLUDE:'utilities\strings.bas' '$INCLUDE:'subs_functions\extensions\opengl\opengl_methods.bas'