Gosub (function no.) 243 [nnn, Goto (function no.) 244 [nnn – Industrial Data Systems IDS Scale Basic User Manual
Page 26
Scale Basic 4.2E
Reference
Get id, Memory1
Open Id 25
If, Zero
If the Id was not found
Error msg, 8
display error message 8
End
if
End
if
End
End
of
function
Gosub
(function
no.)
243
[nnn]
Purpose: to execute a function (subroutine) from within a function and return to the calling
function at the instruction after the Gosub instruction.
Remarks: a subroutine can be called from within a subroutine (this is called nesting). The
maximum level of nesting is 8; i.e. function1
→
function6
→ function7 → function2 …
maximum = 8 levels.
Example: in a bulk-weigh function the scale is zeroed, the display is set to Net mode, and relay1
is turned on.
Gosub,
Zero
Zero
the
scale
Gosub, Set net
Set the display to net mode
Relay on, 1
Turn on relay 1
End
End
of
function
Goto
(function
no.)
244
[nnn]
Purpose: transfer execution from one function to another.
Remarks:
Example:
If, Flag4
If flag4 is on
Goto,
7 Go
to
function
7
End
if
End
if
Set pt, On, 2
Turn on setpoint 2. This instruction is not
executed if Goto was executed.
If (condition) / Else / End if
241 [nnn] / 251 / 240
Purpose: to control program flow using a condition code.
Remarks: the instructions after the if statement are executed if the condition code is true, the
instructions after the Else statement are executed if the condition code is false. The Else part
of the instruction is optional. The End if statement ends the If statement.
Example: the F1 key (activates function1) is used to toggle the display between net weight and
memory1 (total). Flag1 is used to determine the current state of the display, Flag1 = True =
display total.
If, Flag1
If current mode = display total
Flag
off,
1
turn
off
flag
1
Display
Net
set
to
display
Net
weight
Else
Else
mode not display net>