Shop OBEX P1 Docs P2 Docs Learn Events
Still a Bit Confused — Parallax Forums

Still a Bit Confused

peteraltmanpeteraltman Posts: 4
edited 2007-03-13 19:49 in BASIC Stamp
This forum is great. However, I used· to be real good in GW BASIC I really feel· like a fool asking these questions. So maybe· you guys can help.
I was instructed· by the forum to interpret GW BASIC to Parallax Basic as follows:

GW BASIC -Verison

10 input a
20 if a=1 then 30
21 if a= 2 then 40
22 if a= 3 then 50
25 goto 10
HERE IS WHERE MY PROBLEMS LYE: I was intructed to use labels. Can someone explain how I would use (gwbasic· format ) 20 if a = 1 then 30: Parallax, how would I write the goto· LABEL to replace the line # 30?

30a=a+32[noparse]:p[/noparse]rint a:goto 60
40a=a+64[noparse]:p[/noparse]rint a:goto 60
50:a=a+128: print a:goto 60

Thanks Again and if you r in NYC. Lunch is on me.

Pete

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-03-13 19:25
    a VAR byte (up to 255)
    start:
    if a = 1 then goto label1 (Look in the manual for the exact syntax, I have to every time.)
    if a = 2 then goto label2 (don't remember if you need the goto or not. The manual knows)
    ....

    label1:
    do this

    label2:
    do that

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-13 19:36
    Some general rules:
    1) There are no numeric labels and lines are not numbered
    2) Labels are typical program names, they start with a letter and can consist of letters and digits
    3) You can translate something like GW BASIC to PBasic, but there are simpler control statements in PBasic that can make a lot of labels unnecessary. Your example would be:
    L10:
      debugin dec a
      if a = 1 then L30
      if a = 2 then L40
      if a = 3 then L50
      goto L10
    L30: a = a + 32
      debug dec a
      goto L60
    L40: a = a + 64
      debug dec a
      goto L60
    L50: a = a + 128
      debug dec a
      goto L60
    L60:
    


    A more compact version would be:
    do
      debugin dec a
      select a
      case = 1
        a = a + 32
        debug dec a
      case = 2
        a = a + 64
        debug dec a
      case = 3
        a = a + 128
        debug dec a
      endselect
    loop
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-13 19:49
    This is a duplicate thread...Please refer to the original thread at the following link.

    http://forums.parallax.com/showthread.php?p=637548

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.