Shop OBEX P1 Docs P2 Docs Learn Events
Programming Newbie Help — Parallax Forums

Programming Newbie Help

peteraltmanpeteraltman Posts: 4
edited 2007-03-13 15:12 in BASIC Stamp
I need help with paralax· basic stamp homework board. I am familier with old GW Basic from the old days of DOS and I use to be good. Now that I have been assigned a new project utilizing· PAralax controllers, I· NEED HELP.
Could anyone tell me how I would transcribe the the following GW BASIC statement into V2.5
1Dim x$
2 input x$
10 If x = 1 then goto 20
11 if x· = 2 then goto 30
12 if x =· 3 then goto·40
13 goto 2


Thanks again to anyone who can help. I have now used BASIC in years and it was always my favorite.

Pete

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-12 22:25
    Pete,

    ·· You can try this…Since x is an integer and not a string there’s no need to declare an array. X is declared as a byte…the DEBUGIN will get the input from the DEBUG window, although it could come from anywhere (you did not specify). The next line branches based on the value of X. You only need to trap if you might receive a value outside that range, in which the program will fall through. Also see the BRANCH instruction for another way to do this.

    [color=#000000]X  VAR  BYTE[/color]
     
    [color=#000000]DEBUGIN DEC X[/color]
     
    [color=#000000]ON X GOTO Label_1, Label_2, Label_3[/color]
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-03-13 15:12
    1Dim x$
    2 input x$
    10 If x = 1 then goto 20
    11 if x = 2 then goto 30
    12 if x = 3 then goto 40
    13 goto 2


    X VAR WORD
    MAIN:
    SERIN 16, 16468, [noparse][[/noparse]DEC X]
    IF X = 1 THEN Do20
    IF X = 2 THEN Do30
    IF X = 3 THEN Do40
    GOTO MAIN

    Do20:
    ' do whatever
    GOTO MAIN

    Do30:
    ' do whatever
    GOTO MAIN

    Do40:
    ' Do whatever
    GOTO MAIN

    And Chris is correct:
    ON X DoNothing, Do20, Do30, Do40

    Would do almost the same thing...
Sign In or Register to comment.