26 of 208
ZBasic Language Reference 18 ZX Microcontroller Family Option X10Interrupt Option X10Interrupt <external interrupt designator> Default: INT0 This option, available only on ATmega-based ZX devices, allows you to specify the external interrupt to be used for the zero-crossing input needed for the low-level X-10 routines. If used, it must appear for the first time in the first module compiled and it must appear after the target device is specified. This option is not supported on VM devices with a VM version older than v3.0.6 and, moreover, only INT0 or INT2 may be specified for VM devices. For native mode devices, it is not supported on xmega-based devices and on mega-based devices the choice is limited to the external interrupts supported by the device in the range INT0 through INT7 . Example Option X10Interrupt INT2 2.3.2 The Definitions Section The definitions section of a ZBasic program may contain constant definitions, variable definitions, subroutine definitions and function definitions. There may be any number of each of these types of definitions and the definitions may occur in any order. It is a common practice, however, to place constant and variable definitions at the top of the definitions section followed by subroutine and function definitions. On the other hand, some programmers prefer to define the constants and variables closer to the routine or routines that use them. BasicX Compatibility Note In BasicX mode, all variables and constants must be defined before the first subroutine or function in a module. Each of these program items may be defined to be Public or Private. A public item is visible to other modules and may be referenced in the definitions contained in other modules. A private item is visible only within the module in which it is defined. Generally speaking, unless there is a specific need for an item to be public, it should be private. If you make something private and later decide that you need to reference it in another module, it is a simple matter to change the definition from private to public. Defining Constants It is often convenient to define constants that can be used in other parts of the program. Doing so generally helps clarify the purpose of the value, assuming a reasonably descriptive name is chosen, and also facilitates easier maintenance and modification of the program. The syntax for defining a constant is as follows: [Public | Private] Const <name> As <type> = <value> If neither Public nor Private is specified, the constant will be private. The <name> must be a legal identifier as described in Section 2.1. The <type> must be one of the fundamental data type names described in Section 2.2 or an Enum type (described in Section 3.2). Lastly, the <value> element must be value or an expression that has a constant value and is the same type as (or compatible with) the specified <type>. In many cases, the <value> will be a simple numeric literal like -55 or 3.14159. In the case of string constants, it may be a literal string like "Hello, world!". However, it is sometimes convenient to define a constant in terms of another constant. Consider the example below.