Breaking out of a Sub?
Posted: 04 June 2010, 14:37 PM
I'm creating a subroutine and there are several points where I want to break out of the routine at certain points if certain conditions are met.
In PBASIC I would simple use a RETURN inside a conditional statement. It doesn't look like ZBasic has anything like "RETURN". . .does that mean I'm going to have to create large nested conditional statement for these subs? That will certainly work, but seems very complicated.
Here's the PBASIC code I'm trying to replicate (there are many more statement like this below, so we're talking "super nesting" I think):
-Jeff
In PBASIC I would simple use a RETURN inside a conditional statement. It doesn't look like ZBasic has anything like "RETURN". . .does that mean I'm going to have to create large nested conditional statement for these subs? That will certainly work, but seems very complicated.
Here's the PBASIC code I'm trying to replicate (there are many more statement like this below, so we're talking "super nesting" I think):
Code: Select all
IF ( (OOCS_Scope_Module = 1) AND (Ignore_Scope_Safety = 0) ) THEN
IF (Scope_Status = 0) THEN
Message(0) = "D"
Message(1) = 0
Message(2) = ">"
GOSUB Send_Update
Message(0) = "<"
GOSUB Send_Update
RETURN
ENDIF
ENDIF
IF ( (OOCS_Voltage_Module = 1) AND (Requested_Roof_State = OPEN) AND (Ignore_Voltage = 0) ) THEN
IF (volts < 194) THEN
Message(0) = "D"
Message(1) = 1
Message(2) = ">"
GOSUB Send_Update
Message(0) = "<"
GOSUB Send_Update
RETURN
ENDIF
ENDIF