Custom array of ports using array?
Is it possible to make an array, where each element equates to a non-consecutive port.
Example:
RELAY VAR BIT[10]
' (obviously, this doesn't work, but it does crash the compiler)
SYMBOL RELAY[1] = PORTB.6
SYMBOL RELAY[2] = PORTC.4
SYMBOL RELAY[3] = PORTD.2
...
' cycle through relays
for i = 1 to 3
RELAY[i] = %1
PAUSE 1000
RELAY[i] = %0
PAUSE 300
next i
Makes a case for functions with pass-by-reference
Bummer,
It's these little things that make programming clean and respectable.
Still, it seems a shame that I can create an aliassed variable that is equivilent to a pin, but not an array element. Seems like the same type of technology.
So close, yet so far.
Thanks so much for your input, everyone.
Bruce and Darrel Cheated!!!
Bruce and Darrel,
You guys cheated(lol). Paul and Ingvar got the job done tidely with PBP. You had to resort to Assembly;).
This is what I love about this forum. Bright, capable folks working together to make a good product (PBP) work even better! I knew in my initial post that there just had to be a way to do this, it just was not documented and was beyond my basic skills. Great learning oppurtunity. I think this is worth putting in the FAQ (in some form) for others to reference later.
Even though it wasn't my post originally, thanks guys for the great lessons.
Cheers,
Steve