Hello Boriel, my first post here, so I'm sorry it's to report a bug.
I found a problem when comparing a ULONG variable with any entry in an array of ULONGs.
Saving the array entry to a temporary ULONG variable to compare with is a workaround.
The problem seems to happen with v1.87, so is perhaps an older bug.
A working code comparison sample is pasted below.
The code purpose is to find where to insert a page number in an array of page numbers, where the pages are stored in correct sequence but are not simply incrementing numbers.
Switch between SUBs v1() / v2() to compare the output.
Thanks
I found a problem when comparing a ULONG variable with any entry in an array of ULONGs.
Saving the array entry to a temporary ULONG variable to compare with is a workaround.
The problem seems to happen with v1.87, so is perhaps an older bug.
A working code comparison sample is pasted below.
The code purpose is to find where to insert a page number in an array of page numbers, where the pages are stored in correct sequence but are not simply incrementing numbers.
Switch between SUBs v1() / v2() to compare the output.
Thanks
Code:
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Declarations
DIM ulStoryPage, ulTemp AS ulong
DIM ulLongStory (5) AS ulong => { 900000, 700000, 500000, 300000, 100000, 0 }
DIM uiCounter, uiPosition, uiYPos AS ubyte
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Inits.
LET uiCounter = 5 : LET uiPosition = 5 : LET uiYPos = 10
LET ulStoryPage = 500001
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Cosmetics
BORDER 0
INK 1
PAPER 0
BRIGHT 1
CLS
PRINT AT 0,0; "Story Page = "; ulStoryPage
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Toggle this between v1() and V2() to compare.
v1() ' v1() fails the comparison against the array.
'v2() ' v2() uses a temp variable to store / compare array value.
DO
LOOP
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SUB v1() ' Find the page position in the story - V1... This fails the comparison, so the page is never inserted.
DO
LET uiCounter = uiCounter - 1
IF ulStoryPage > ulLongStory(uiCounter) ' Trying to compare the ULONG against the ULONG in the array.
LET uiPosition = uiCounter
PRINT AT uiYPos,0; INK 4; "Slot=";uiCounter; " Page="; ulLongStory(uiCounter); " insert @"; uiPosition
ELSE
PRINT AT uiYPos,0; INK 2; "Slot=";uiCounter; " Page="; ulLongStory(uiCounter)
ENDIF
LET uiYPos = uiYPos + 1
LOOP UNTIL uiCounter = 0
END SUB
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SUB v2() ' Find the page position in the story V2... Assigns the array value to a temp value to compare. (This works)
DO
LET uiCounter = uiCounter - 1
LET ulTemp = ulLongStory(uiCounter) ' Using a temporary ULONG to compare with instead of the array.
IF ulStoryPage > ulTemp
LET uiPosition = uiCounter
PRINT AT uiYPos,0; INK 4; "Slot=";uiCounter; " Page="; ulLongStory(uiCounter); " insert @"; uiPosition
ELSE
PRINT AT uiYPos,0; INK 2; "Slot=";uiCounter; " Page="; ulLongStory(uiCounter)
ENDIF
LET uiYPos = uiYPos + 1
LOOP UNTIL uiCounter = 0
END SUB