Shop OBEX P1 Docs P2 Docs Learn Events
Program flow control: this is so lame — Parallax Forums

Program flow control: this is so lame

Gerry ShandGerry Shand Posts: 45
edited 2010-02-23 04:49 in BASIC Stamp
First of all I am going to apologize for this post but I am having issues trying to do program flow control using "If ... Then" statements and could not find anything in the archives. But I am tired so the answer is probably pretty obvious to the group here and another set of eyes always helps.

Here goes:

In trying to do program flow control, this is a chunk of what I have been doing:

Relay1:
If x=1 then Relay2
goto Relay3

Relay2:
Do task A
If y=6 then Relay 4

Relay3:
Do task B

Relay4:
Do task C

Goto Relay1

This works but the big question is: Can this be done more elegantly so I use less space in the BS-2? I have tried using IF THEN ELSE without any luck. Maybe something with a Branch command?

Any thoughts would be appreciated and thanks in advance for any pointers.

Gerry, the tired

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-02-23 04:49
    I can get·rid of a GOTO:
    Relay1:
    [color=red][s]If x=1 then Relay2[/s][/color]
    [color=red][s]goto Relay3[/s][/color]
    IF x <> 1 THEN Relay3
    
     
    Relay2:
    "do task A"
    IF y = 6 THEN Relay4
     
    Relay3:
    "do task B"
     
    Relay4:
    "do task C"
    GOTO Relay1
    
Sign In or Register to comment.