93 of 172
ZBasic Language Reference 86 ZX Microcontroller Family 3.25.1 Structures in Persistent Memory and Program Memory Structures in Persistent Memory and Program Memory may be defined using the syntax: {Public | Private | Dim} <name> As Persistent <type> or {Public | Private | Dim} <name> As ProgMem <type> where <type> is the name of a previously defined structure. The allowable members of a Persistent Memory or Program Memory structure are the intrinsic types Byte, Integer, UnsignedInteger, Long, UnsignedLong, Single, bounded strings, arrays of those types and other structures containing only those types. Arrays of structures in Persistent Memory or Program Memory may be defined by specifying the dimensions in the usual way. It is permissible to directly assign between any combination RAM-based, Persistent Memory and Program Memory variables defined using the same structure. Similarly, direct comparison between like structures (equality and inequality only) is supported. 3.26 Data Type Implementation Information This section provides more information on the technical details of the fundamental data types and variants. Although this information is generally not needed to write properly functioning programs it is provided for those who are interested and for the special cases where knowledge of such implementation details may help you implement your application. To review, the table of fundamental data types introduced earlier in this manual is reproduced here with an additional column indicating the amount of space required for each type. Fundamental Data Types Data Type Name Range of Values Size in Bytes Boolean True, False 1 Byte 0 to 255 1 Integer -32,768 to 32,767 2 UnsignedInteger 0 to 65,535 2 Long -2,147,483,648 to 2,147,483,647 4 UnsignedLong 0 to 4,294,967,295 4 Single approx. ±1.4e-45 to ±3.4e+38 and 0.0 4 String 0 to 255 characters See 3.26.2 The Boolean type, while occupying an entire byte, will always contain one of two values under normal circumstances. The value True is represented by the value 255 and the value False by 0. If your application has a need for a lot of Boolean variables it may be more efficient to use the Bit data type described in Section 3.22. The primary disadvantage to using the Bit type is that it cannot be passed by reference. The Single type is implemented using the data format specified in the IEEE 754 standard for single precision floating point numbers. 3.26.1 User-defined Type Details The user-defined types in ZBasic are enumerations and structures. Enumerations are implemented using a two-byte value to represent the enumeration member value. Structures are laid out in memory exactly corresponding to the order in which the members are defined in the structure definition. Bit and Nibble type members are aligned on bit and nibble boundaries, respectively. All other member types are aligned