CompuServe Messages

#FOR…BY -1 bug

    26-May-89 22:08:11
Sb: #FOR…BY -1 bug
Fm: bob hawkins 70345,425
To: Martin Taillefer
Thanks for the reply about .key, but I still don't know why its there. Now I have another, more serious, problem to report, The following program either Gurus (most of the time), or fails to stop when i=0, wrapping around to i=65535 and continuing. In that case, it runs forever. If it runs forever, it does so every time its run: MODULE GuruCall; FROM InOut IMPORT WriteCard, WriteString, WriteLn; VAR i : CARDINAL; BEGIN FOR i := 10 TO 0 BY -1 DO (* This gets the Guru almost every time *) WriteString("Loop index = "); WriteCard (i, 10); WriteLn; DEC(i); END; (* FOR *) END GuruCall. If the FOR-statement is replaced by the equivalent WHILE i>0…DEC(i) construct, it works properly. It's the "BY -1" that seems to do it. "FOR i:=0 TO 10 DO" works fine. "BY 2" seems to work OK. I haven't figured out why it Gurus sometimes and runs forever on some compiles. Linking with RTR or just RT didn't make any difference. I am running Kickstart 1.2 with the appropriate SetPatch, WB 1.3, the ARP 1.3 commands and library but not the ARP shell, on an Amiga 1000 with a Starboard 2 meg on the side and four floppies, morerows, FaccII and vd0:.