46 of 208
ZBasic Language Reference 38 ZX Microcontroller Family Case 4, 5 To 20, 27 j = 1 Call PutPin(13, zxOutputLow) Case 3, 100, Is > 200, j j = 0 Case Else j = -1 End Select In the example above, if the selection expression evaluates to 3 the statements of the first case clause will be executed. The fact that the third case clause also has a case value of 3 is of no consequence. Also note that the case expressions are evaluated every time they are tested. This fact must be kept in mind for two reasons. Firstly, if the case expression contains a variable whose value changes between successive executions of the Select-Case statement (a situation that is strongly discouraged), the case clause that is selected may change even if the selection expression value does not change. Secondly, if any of the case clause expressions involves a function call, the function may or may not be invoked depending on the value of the selection expression and the values of the various expressions in the case clauses preceding it. BasicX Compatibility Note In BasicX mode, the use of String and Single types is not supported nor is the construction Is <op> <expr>. Moreov er, there must be at least one standard case clause. 2.5.13 Set Statement This statement is only allowed as the first statement of a function that returns an UnsignedInteger or UnsignedLong type. It must precede all other statements and variable definitions. It is supported for compatibility with BasicX and is required in BasicX compatibility mode but it is otherwise ignored. The syntax is shown below. Set <function-name> = New <type> The <function-name> element must match the name of the function containing the Set statement and the <type> must match the function’s type. Example Function myFunc() as UnsignedInteger Set myFunc = New UnsignedInteger Dim I as Integer <other-statements> End Function 2.5.14 While-Wend Statement For compatibility with other dialects of Basic, ZBasic includes support for an alternative to the Do While – Loop construct. The syntax is: While <boolean-expression> [<statements>] Wend