Page 50 of 229 Start Back Next End ZBasic Language Reference 40 ZBasic Microcontrollers There are two special forms of case expressions that may be used in the <case-expr-list> of a standard case clause. The first special form is the range expression. This takes the form of two expressions separated by the keyword To. Both expressions must evaluate to the same type as <test- expr>. The <test-expr> value will be deemed to select the case clause if the value is greater than or equal to the value of the expression to the left of the To keyword and less than or equal to the value of the expression to the right of the To keyword. Effectively, the range expression specifies an inclusive range. The second special form may be used to implement special test conditions. It has the syntax: Is <conditional-operator> <expression> The <conditional-operator> element may be any one of the six conditional operators: =, <>, <, <=, >, and >=. The <expressi on> element must be an expression that evaluates to the same type as the <test-expr>. Note that the construction Is = <expr> yields the same result as simply specifying the expression value alone. There is no fixed limit on how deeply Select-Case statements may be nested. The actual limit is governed by how much memory is available to the compiler. For all practical purposes, there is no limit. Example Select Case i * j Case 3 j = 5 Call PutPin(12, zxOutputLow) 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>. Moreover, 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