03-12-2024, 12:39 PM
(This post was last modified: 03-15-2024, 08:56 PM by boriel.
Edit Reason: use code slug
)
I have a subroutine that works well most of the time but sometimes gives an error.
Once every few hundred iterations it gives an error.
I tried changing the mathematical expression but it continues to give errors - sometimes in the old expression, other times in the new expression.
Intermittent errors also occur on other lines of this routine.
I tried changing the type of variables but it also gave errors.
Am I doing something wrong or is the compiler wrong?
If I delete most of the program the intermittent error may continue to appear or may stop appearing.
Does anyone have any idea what could be causing this?
Simplified routine:
Once every few hundred iterations it gives an error.
I tried changing the mathematical expression but it continues to give errors - sometimes in the old expression, other times in the new expression.
Intermittent errors also occur on other lines of this routine.
I tried changing the type of variables but it also gave errors.
Am I doing something wrong or is the compiler wrong?
If I delete most of the program the intermittent error may continue to appear or may stop appearing.
Does anyone have any idea what could be causing this?
Simplified routine:
Code:
SUB print_sprite (x0 AS LONG, y0 AS LONG)
DIM x,y AS LONG
DIM Width,Height AS LONG
DIM xold AS LONG
LET xold=x0-INT(SPRITES(ix_SpriteWidth)/2)
LET Width=SPRITES(ix_SpriteWidth)
LET x=x0-INT(Width/2)
IF x<>xold THEN PRINT AT 10,10;" xold=";xold;" x=";x: PAUSE 0
END SUB
LET SPRITES(ix_SpriteWidth) = 8
print_sprite(236,46)
' sometimes printout is
xold=232 x=236
'x in error
print_sprite(84,90)
' sometimes printout is
xold=84 x=80
'xold in error