PBP syntax - numbering variable


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default PBP syntax - numbering variable

    Hello

    I just saw this piece of code in another thread
    (http://www.picbasic.co.uk/forum/show...hlight=I2CREAD):
    Code:
    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:
    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...
    Last edited by flotulopex; - 9th January 2007 at 19:30.
    Roger

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Toggle works with just the pin number.

    I.E. Toggle 0 will toggle GPIO.0, Toggle 1 will toggle GPIO.1, etc, so;
    Code:
    MAIN:           
        for Counter = 0 to 2
            Toggle Counter ' another way
            pause 200
        next counter
        goto main
    should do what you're looking for.
    Last edited by Bruce; - 9th January 2007 at 20:26.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hello
    Is it possible to do the same for this code:
    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

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Thumbs up "REFERENCE" is the correct term

    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 ;-)
    Roger

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Because of you, skimask, I'll need to study a few hours more... Thank you very very much for this ;-)
    eh...sorry 'bout that....

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Wink

    At least you didn't ruine his life...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Keeps him off the street and out of trouble! Good Job!
    _____________________________________________ snicker , he he he!
    Last edited by Archangel; - 12th January 2007 at 01:16.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    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)

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Damn... since the last few days, i ruine 2 life. 2007 begin really bad
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. pbp - asm variable passing
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th May 2009, 08:49
  3. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Replies: 2
    Last Post: - 10th July 2006, 01:05

Members who have read this thread : 0

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