Varible Indexing

Discussion in 'Embedded Systems and Microcontrollers' started by JSBIII, Apr 27, 2010.

  1. JSBIII

    Thread Starter New Member

    Jan 19, 2010
    2
    0
    Hello,

    I need help with establishing a method of using a varible to index a For Next Loop.

    Example:

    IF Input = 1 THEN
    FOR XX = 0 to 3
    PORTB.XX = REGISTER.XX
    NEXT XX
    ENDIF

    I have tried variations of this example but I can not transfer the state of PORTB.0 - 3 to the REGISTER. I am using PICBASIC Pro and a PIC16F628.
    Does anyone have any suggestions?

    Thanks
     
  2. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Can you do it like this (as shown in post #6 in this PBP thread: How to blink 8 LEDs...)?

    Code ( (Unknown Language)):
    1.  
    2. For x = 0 to 3
    3.     PORTB.0(x) = register.0(x)
    4. next x
    5.  
     
    JSBIII likes this.
  3. JSBIII

    Thread Starter New Member

    Jan 19, 2010
    2
    0
    I see - you need to bracket the variable. Thanks
     
Loading...