FAQ  •  Register  •  Login

v1.8.9 : IF / ULONG > ULONG() array comparison bug

<<

JMcGibbitts

Posts: 2

Joined: Tue Feb 05, 2019 7:44 pm

Post Tue Feb 05, 2019 8:03 pm

v1.8.9 : IF / ULONG > ULONG() array comparison bug

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

  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
<<

boriel

Site Admin

Posts: 1538

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sat Feb 09, 2019 5:13 pm

Re: v1.8.9 : IF / ULONG > ULONG() array comparison bug

This bug was fixed in version 1.8.8

Please download 1.8.9 and try. I've checked and your program run ok :)
<<

JMcGibbitts

Posts: 2

Joined: Tue Feb 05, 2019 7:44 pm

Post Sat Feb 09, 2019 7:41 pm

Re: v1.8.9 : IF / ULONG > ULONG() array comparison bug

I have just used my local v1.8.9 zip to update the directory again, checked I copied everything across. It runs just fine. I apologize, as it seems for some stupid reason I must not have properly updated my install even since v1.8.7. :oops:
<<

boriel

Site Admin

Posts: 1538

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Feb 10, 2019 11:43 pm

Re: v1.8.9 : IF / ULONG > ULONG() array comparison bug

No worries! Indeed compiling programs is the best way to find new bugs. :wink:
For the 1.9.x (currently I'm a bit busy) a lot of testing will be needed since it changes a lot in the optimizer.

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO