Page 84 of 229 Start Back Next End ZBasic Language Reference 74 ZBasic Microcontrollers #if <expression> <other-text> #elseif <expression> <other-text> #else <other-text> #endif The <expression> element may be any legal ZBasic expression involving constants, conditional identifiers, ZBasic operators and ZBasic System Library functions that can be evaluated at compile time. The usual type-compatibility rules apply, e.g., you cannot add an integral value and a string value. Additionally, the special operator defined() may be used in a conditional expressions. The parameter to the defined() operator should be an identifier and the result will be non-zero or zero depending on whether the identifier is defined or not. Examples #if defined(EXPERIMENTAL) Debug.Print "Experimental version" #endif #if defined(Pin.RedLED) Call PutPin(Pin.RedLED, zxOutputLow) #endif The #elseif clause in the conditional construction may appear zero or more times. The #else clause may appear at most once. The <other-text> element represents arbitrary text and may contain other conditional constructs. There is no practical limit on the nesting of conditionals. Examples #if Version >= 23 #ifdef EXPERIMENTAL ' prepare the external circuitry and activate it Call TestSetup(i) Call PutPin(12, j) #endif #endif #if (Version >= 23) And (EXPERIMENTAL <> 0) ' prepare the external circuitry and activate it Call TestSetup(i) Call PutPin(12, j) #endif The two examples above have the same effect. Conditional identifiers may be used in definitions, statements, and expressions as if they were constants defined using the Const definition (but the converse is not true). #define Version "V1.0" #define arraySize 26 Dim myArray(1 To arraySize) as Byte debug.print Version One implication of this is that adding a definition of a conditional identifier may result in a compiler message related to a Const definition warning about duplicate definitions. Conditional identifiers defined