PDA

View Full Version : FOR-NEXT loop question



wcpesp
- 6th February 2013, 17:01
Its been years since I programmed in BASIC, but I have used FOR-NEXT loops successfully, in alot of programs. I'm having trouble with the following example usage, PBP keeps giving me a syntax error.......

cycles VAR WORD

cycles = 15

For i = 1 to cycles <== this line is flagged as a sytax error

<do something in here>

Next i

end


This is just an example, its not my real program. I believe the issue is that PBP expects me to give it a firm number or constant for the number of loops, it doesnt like the "cycles" variable. I really need to have a variable, though. Can someone help?

Thanks,

Bill

Darrel Taylor
- 6th February 2013, 17:38
Variables are fine in a FOR loop.

But did you create an i variable?

i VAR WORD

wcpesp
- 6th February 2013, 17:48
Ah Ha! Thats it! :smile:

No, I absolutely forgot to set up i as a variable. I never had to do that in my old versions of BASIC. Thats my excuse and I'm sticking to it!

Thanks very much for lending me a hand, Darrel.

Bill