Navigation bar
  Start Previous page
 34 of 169 
Next page End  

ZBasic Language Reference
27
ZX Microcontroller Family
2.5.2 Call Statement
The Call statement is used to invoke a subroutine.  The syntax is:
Call <subroutine-name> ( [<parameter-list>] )
The optional <parameter-list> must contain the proper number of parameters each of the correct
type for the subroutine being invoked.  If more than one parameter is given each parameter must be
separated from the next by a comma.
When this statement is executed the supplied parameters, if any, are pushed on the stack and control is
transferred to the first statement of the subroutine.  When the subroutine finishes executing control
resumes with statement following the Call statement.
Although not recommended, for compatibility with other Basic dialects it is permissible to omit the Call
keyword.  If this is done the parentheses surrounding the parameter list must also be omitted.  Note,
particularly, the third example below that seems to violate this rule.  However, it does not because a
parenthesized expression is, in fact, an expression.
Examples
Call PutPin(12, 0)
PutPin 12, 0
Delay (1.0)
2.5.3 CallTask Statement
The CallTask statement is used to start a task.  See Section 3.5 for more information on using tasks.  The
basic syntax to invoke a task is:
CallTask <task-name>, <task-stack>
In this case, the <task-name> element must be the name of a user-defined subroutine (usually one that
takes no parameters).  The <task-stack> must be the name of a Byte array that will serve as the stack
for the task.  For compatibility with BasicX, the <task-name> may be enclosed in quote marks.
Example
Dim ts1(1 to 40) as Byte
CallTask task1, ts1
A task may also be passed parameters when it is invoked.  The syntax for doing so is similar to that for
invoking a subroutine that requires parameters.
CallTask <task-name>( <parameter-list> ), <task-stack>
See the discussion of the CallTask statement in the ZBasic System Library Reference manual for more
details on the allowed parameter types.  This syntax is not supported in BasicX compatibility mode.
Previous page Top Next page