PDA

View Full Version : Newb question, Objects



dr.video
01-25-2008, 01:27 AM
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

Dgswaner
01-25-2008, 01:31 AM
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 Green
01-25-2008, 01:57 AM
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.