FOR-NEXT loop question


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2013
    Posts
    7

    Default FOR-NEXT loop question

    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

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: FOR-NEXT loop question

    Variables are fine in a FOR loop.

    But did you create an i variable?

    i VAR WORD
    DT

  3. #3
    Join Date
    Feb 2013
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: FOR-NEXT loop question

    Ah Ha! Thats it!

    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

Similar Threads

  1. FOR..NEXT Loop Bug?
    By MSapper in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th April 2011, 01:04
  2. Gosub in a while loop Question
    By lerameur in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th November 2010, 16:42
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. Help with loop
    By wildbilly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd January 2007, 16:59
  5. very simple loop question
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th January 2006, 06:45

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts