I've had a problem with the FOR..NEXT loop in a couple of projects in the past and it just happened again. I thought this time I would see if it's something I'm doing or a problem with the compiler. Basically I'm using a FOR..NEXT loop to initialize some data in a serially connected Amulet LCD touch screen.
The FOR..NEXT loop which does not work is as follows:
FOR i = 32 to i = 37
addVar = i
GOSUB SetByte
Next i
SetByte:
SEROUT2 tr,84,[$D5,hex2 addVar,hex2 TByte]
SERIN2 rx,84,500,SetByte,[In[0]]
IF In[0] <> $F0 then SetByte
Return
The above code will not work. However the code below will properly set the Amulet variables.
addVar = 32
GOSUB SetByte
addVar = 33
GOSUB SetByte
addVar = 34
GOSUB SetByte
AddVar = 35
GOSUB SetByte
addVar = 36
GOSUB SetByte
addVar = 37
GOSUB SetByte
Any insight would be appreciated. For now I'm avoiding using FOR..NEXT loops.
Thank You
Mike
Bookmarks