Shop OBEX P1 Docs P2 Docs Learn Events
Newb question, Objects — Parallax Forums

Newb question, Objects

dr.videodr.video Posts: 5
edited 2008-01-24 18:57 in Propeller 1
I know this will such a newb question
I have a Main OBJ and in that object I have several other objects that run and return in sequence, if I have an object that may have several outcomes that need to run different objects then return to the Main obj sequence. Like GOTO or GOSUB.


Main

start

power_up

check_for_input ' Here if there is no input then I want to goto power_down
"if there is input then I want to start_show
start_show

check_for_input 'Here if there is input then I want to start_show, if not then power_down

power_down


I have written this code in BasicSX and has run for couple of years, no I am trying to use the power of Propeller.

Thanks so much

Dr.Video

Comments

  • DgswanerDgswaner Posts: 795
    edited 2008-01-24 18:31
    if your calling them repeatedly and branching to different functions or objects I would keep that code in the main part of your code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

    DGSwaner
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-24 18:57
    Here's an example
    PUB main
       start
       power_up
       repeat while check_for_input
          start_show
       power_down
    
    PRI start
    
    PRI power_up
    
    PRI check_for_input
       if input_ok
          return true
       else
          return false
    
    PRI start_show
    
    PRI power_down
    
    


    Keep in mind that Spin does not have a GOTO or labels, but has a rich group of program control statements.
Sign In or Register to comment.