31 of 158
25 2.5.1 Assignment Statement The assignment statement is perhaps the most basic and most often used statement in a program. The syntax of an assignment statement is shown below in two forms, one for assigning a value to a scalar variable and one for assigning a value to an array element. <var-name> = <value> <var-name>( <index-list> ) = <value> In both cases, the <value> element may be a simple value or a complex expression involving one or more other variables, constants, functions, etc. However, the type of <value> must match the type of the variable or array element to which it is being assigned. There is no automatic type conversion. When assigning a value to an array element, you must specify the index or indices of the particular element of interest. For a single-dimensional array, you will specify a single value for the index of the desired element. For multi-dimensional arrays, you must specify a value for each of the indices separated from one another by a comma. Example Dim i as Integer Dim ia(1 to 5) as Integer Dim board(1 to 12, 1 to 12) as Byte i = 2 ia(i) = (ia(3) + 2) / 4 board(i, 6) = CByte(ia(2)) 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: