Shop OBEX P1 Docs P2 Docs Learn Events
Another HB-25 Motor Controller code question — Parallax Forums

Another HB-25 Motor Controller code question

Joe FishbackJoe Fishback Posts: 99
edited 2009-04-09 20:24 in Robotics
In the documention and sample code for the HB-25 I have questions about the syntax of the code use of the "colon". On the first line of the Initialization part of the program is···· DO: LOOP UNTIL HB25 = 1 . Why is it written that way and not· on two lines

DO
LOOP UNTIL HB = 1

I have also noticed on other code samples a "colon" between statements on one line instead of putting them on seperate lines. What·are the rules for using the "colon" ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
······ Joe Fishback

-Robots are my friends-

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-04-09 01:27
    Why waste two lines when one will do? The entire command fits on one line like an if/then statement with only one statement like:
    if i > 5 then goto someplace

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-04-09 15:59
    Hi Joe,

    In PBASIC, a colon can substitute a carriage return in your code. So, you can use a colon anytime you need a new line but don't want to take the space. As Franklin said, why waste two lines when one will do? [noparse]:)[/noparse]

    However, the colon cannot be used when executing subroutines. This is because the code cannot return to the point where the subroutine was called if it is not in a new line. Just something to keep in mind if you decide to try using colons in your own code.

    Hope this helps!

    Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax, Inc.
  • Joe FishbackJoe Fishback Posts: 99
    edited 2009-04-09 20:24
    Jessica,

    Thanks, I could not find·anything in the manual on the use of the "colon". That explains alot.






    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ······ Joe Fishback

    -Robots are my friends-

    Post Edited (Joe Fishback) : 4/9/2009 11:42:31 PM GMT
Sign In or Register to comment.