PDA

View Full Version : PBP syntax - numbering variable



flotulopex
- 9th January 2007, 18:58
Hello

I just saw this piece of code in another thread
(http://www.picbasic.co.uk/forum/showthread.php?t=5475&highlight=I2CREAD):
for n=0 to 19
temp1=n+(rec*20)+temp
I2CREAD SDA,SCL,160,temp1,[text[n]]
text[n]=text[n]-48
next n

Is it possible to do the same for this code:
LED var byte[3]
LED0 var GPIO.0
LED1 var GPIO.1
LED2 var GPIO.2
Counter var byte
MAIN:
for Counter = 0 to 2
Toggle LED[counter] '<<<< is this possible another way?
pause 200
next counter
goto main
end

Is thought this syntax would not be possible in PBP and my Editor won't allow this anyway.

I must miss something...

Bruce
- 9th January 2007, 19:42
Toggle works with just the pin number.

I.E. Toggle 0 will toggle GPIO.0, Toggle 1 will toggle GPIO.1, etc, so;


MAIN:
for Counter = 0 to 2
Toggle Counter ' another way
pause 200
next counter
goto main
should do what you're looking for.

skimask
- 9th January 2007, 20:16
Hello
Is it possible to do the same for this code:
LED var byte[3]
LED0 var GPIO.0
LED1 var GPIO.1
LED2 var GPIO.2
Counter var byte
MAIN:
for Counter = 0 to 2
Toggle LED[counter] '<<<< is this possible another way?
pause 200
next counter
goto main
end

Is thought this syntax would not be possible in PBP and my Editor won't allow this anyway.

I must miss something...



Another really excellent writeup on how variables and the like can be used in PBP...
http://www.picbasic.co.uk/forum/showthread.php?t=544

flotulopex
- 10th January 2007, 09:36
Thank you Bruce,

Your code works well.

Due to my ignorance, my example was not a good one... since I need to reference my variables (as I just learned the correct term now).

Sometimes, it is difficult to ask the right question.

Because of you, skimask, I'll need to study a few hours more... Thank you very very much for this ;-)

skimask
- 11th January 2007, 13:46
Because of you, skimask, I'll need to study a few hours more... Thank you very very much for this ;-)

eh...sorry 'bout that....

mister_e
- 11th January 2007, 17:13
At least you didn't ruine his life...

Archangel
- 12th January 2007, 01:14
Keeps him off the street and out of trouble! Good Job!
_____________________________________________ snicker , he he he!

skimask
- 12th January 2007, 03:43
At least you didn't ruine his life...

Like you ruined mine!!! :)

You did it!!....you really did it!! D@mn you...D@mn you all to h#ll!!!!
(Planet of the Apes references in case you didn't know)

mister_e
- 12th January 2007, 03:45
Damn... since the last few days, i ruine 2 life. 2007 begin really bad ;)