mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-07 16:30:18 +00:00
Fix to Issue #233 with $IF and VERSION
https://github.com/QB64-Phoenix-Edition/QB64pe/issues/233 This should fix the comparisons with $IF and VERSION. A few things of note here, which might affect future version labeling: This expects to find version numbers which follow our current style -- ##.##.## -- 3 numbers, separated by periods. Adding in alphabetic characters will basically get ignored, and versions with less than 3 values will generate FALSE results in all comparisons.
This commit is contained in:
parent
6cc0432a99
commit
7576dc46fe
1 changed files with 50 additions and 2 deletions
|
@ -25599,7 +25599,12 @@ FUNCTION EvalPreIF (text$, err$)
|
||||||
END IF
|
END IF
|
||||||
IF INSTR(symbol$, "=") THEN 'check to see if we're equal in any case with =
|
IF INSTR(symbol$, "=") THEN 'check to see if we're equal in any case with =
|
||||||
UserFound = 0
|
UserFound = 0
|
||||||
|
IF l$ = UserDefine(0, 7) THEN 'we're comparing VERSION numbers
|
||||||
|
result = CompareVersions(Version$, r$) '-1 is less than, 0 is equal, +1 is greater than
|
||||||
|
IF result = 0 THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
|
END IF
|
||||||
FOR i = 0 TO UserDefineCount
|
FOR i = 0 TO UserDefineCount
|
||||||
|
IF i = 7 THEN _CONTINUE
|
||||||
IF UserDefine(0, i) = l$ THEN
|
IF UserDefine(0, i) = l$ THEN
|
||||||
UserFound = -1
|
UserFound = -1
|
||||||
IF UserDefine(1, i) = r$ THEN result$ = " -1 ": GOTO finishedcheck
|
IF UserDefine(1, i) = r$ THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
|
@ -25610,7 +25615,12 @@ FUNCTION EvalPreIF (text$, err$)
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
IF INSTR(symbol$, ">") THEN 'check to see if we're greater than in any case with >
|
IF INSTR(symbol$, ">") THEN 'check to see if we're greater than in any case with >
|
||||||
|
IF l$ = UserDefine(0, 7) THEN 'we're comparing VERSION numbers
|
||||||
|
result = CompareVersions(Version$, r$) '-1 is less than, 0 is equal, +1 is greater than
|
||||||
|
IF result = 1 THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
|
END IF
|
||||||
FOR i = 0 TO UserDefineCount
|
FOR i = 0 TO UserDefineCount
|
||||||
|
IF i = 7 THEN _CONTINUE
|
||||||
IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values
|
IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values
|
||||||
IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) > VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck
|
IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) > VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
ELSE
|
ELSE
|
||||||
|
@ -25618,8 +25628,14 @@ FUNCTION EvalPreIF (text$, err$)
|
||||||
END IF
|
END IF
|
||||||
NEXT
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
IF INSTR(symbol$, "<") THEN 'check to see if we're less than in any case with <
|
IF INSTR(symbol$, "<") THEN 'check to see if we're less than in any case with <
|
||||||
|
IF l$ = UserDefine(0, 7) THEN 'we're comparing VERSION numbers
|
||||||
|
result = CompareVersions(Version$, r$) '-1 is less than, 0 is equal, +1 is greater than
|
||||||
|
IF result = -1 THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
|
END IF
|
||||||
FOR i = 0 TO UserDefineCount
|
FOR i = 0 TO UserDefineCount
|
||||||
|
IF i = 7 THEN _CONTINUE
|
||||||
IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values
|
IF VerifyNumber(r$) AND VerifyNumber(UserDefine(1, i)) THEN 'we're comparing numeric values
|
||||||
IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) < VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck
|
IF UserDefine(0, i) = l$ AND VAL(UserDefine(1, i)) < VAL(r$) THEN result$ = " -1 ": GOTO finishedcheck
|
||||||
ELSE
|
ELSE
|
||||||
|
@ -25628,8 +25644,6 @@ FUNCTION EvalPreIF (text$, err$)
|
||||||
NEXT
|
NEXT
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
finishedcheck:
|
finishedcheck:
|
||||||
temp$ = leftside$ + result$ + rightside$
|
temp$ = leftside$ + result$ + rightside$
|
||||||
END IF
|
END IF
|
||||||
|
@ -26063,6 +26077,40 @@ SUB increaseUDTArrays
|
||||||
REDIM _PRESERVE udtenext(x + 1000) AS LONG
|
REDIM _PRESERVE udtenext(x + 1000) AS LONG
|
||||||
END SUB
|
END SUB
|
||||||
|
|
||||||
|
FUNCTION CompareVersions (v1$, v2$)
|
||||||
|
DIM AS LONG p1, p2, p3, p4, p5, p6 'part 1 through 6
|
||||||
|
|
||||||
|
IF GetVersionValues(v1$, p1, p2, p3) = 0 THEN CompareVersions = 666: EXIT FUNCTION 'Evil Error code. Something went wrong!
|
||||||
|
IF GetVersionValues(v2$, p4, p5, p6) = 0 THEN CompareVersions = 666: EXIT FUNCTION 'Evil Error code. Something went wrong!
|
||||||
|
|
||||||
|
IF p1 < p4 THEN CompareVersions = -1: EXIT FUNCTION
|
||||||
|
IF p1 > p4 THEN CompareVersions = 1: EXIT FUNCTION
|
||||||
|
IF p2 < p5 THEN CompareVersions = -1: EXIT FUNCTION
|
||||||
|
IF p2 > p5 THEN CompareVersions = 1: EXIT FUNCTION
|
||||||
|
IF p3 < p6 THEN CompareVersions = -1: EXIT FUNCTION
|
||||||
|
IF p3 > p6 THEN CompareVersions = 1: EXIT FUNCTION
|
||||||
|
|
||||||
|
CompareVersions = 0 'if all else fails, the two versions are equal.
|
||||||
|
END FUNCTION
|
||||||
|
|
||||||
|
FUNCTION GetVersionValues (version$, v1 AS LONG, v2 AS LONG, v3 AS LONG)
|
||||||
|
v$ = version$
|
||||||
|
i = INSTR(v$, ".")
|
||||||
|
|
||||||
|
IF i = 0 THEN EXIT FUNCTION 'if there's no period, then something is wrong with this version
|
||||||
|
|
||||||
|
v1 = VAL(LEFT$(v$, i - 1))
|
||||||
|
v$ = MID$(v$, i + 1)
|
||||||
|
i = INSTR(v$, ".")
|
||||||
|
|
||||||
|
IF i = 0 THEN EXIT FUNCTION 'qb64pe versions have 3 parts separated by 2 periods... If we don't have a second period, something is wrong.
|
||||||
|
|
||||||
|
v2 = VAL(LEFT$(v$, i - 1))
|
||||||
|
v3 = VAL(MID$(v$, i + 1))
|
||||||
|
GetVersionValues = -1
|
||||||
|
END FUNCTION
|
||||||
|
|
||||||
|
|
||||||
'$INCLUDE:'utilities\strings.bas'
|
'$INCLUDE:'utilities\strings.bas'
|
||||||
'$INCLUDE:'utilities\file.bas'
|
'$INCLUDE:'utilities\file.bas'
|
||||||
'$INCLUDE:'utilities\build.bas'
|
'$INCLUDE:'utilities\build.bas'
|
||||||
|
|
Loading…
Reference in a new issue