Page 144 of 229 Start Back Next End ZBasic Language Reference 134 ZBasic Microcontrollers - The system-level details of ZBasic are likely to be different than those of BasicX. For example, the system information related to routine invocation, tasks, queues, etc. is probably not the same as that of BasicX so if your program relies on such information it is likely not to work correctly. Similarly, variable space may be allocated differently than it is for BasicX. If your code relies on certain variables being arranged in memory sequentially it may not work correctly. In general, any BasicX code that relies on internal implementation details needs to be examined carefully. - By default, the ZBasic compiler omits superfluous code and does not allocate space for unused variables. There are compiler options to alter this behavior in case they are needed. - The precedence of operators is different in ZBasic than it is in BasicX. The default operator precedence in ZBasic matches that of Visual Basic. However, in BasicX compatibility mode, the operator precedence matches that of BasicX. If you compile a BasicX program in ZBasic without using BasicX compatibility mode you may have to add parentheses to some expressions to achieve the intended effect. - The Mod operator in ZBasic is sign-correct. In BasicX, the result of a Mod operation on a negative value is (incorrectly) a positive value. - ZBasic supports Mod, multiplication and division operators on UnsignedLong types; BasicX does not. - In ZBasic, enumeration types are represented internally using 16-bit values. In BasicX they are 8-bit values. - In BasicX, all characters on an input line following a comment character are ignored. In ZBasic, an input line is examined to see if it ends with a continuation character before it is examined for comment characters. This means a line ending with a continuation character that is preceded by a comment character will not compile the same in ZBasic as in BasicX. The workaround is to delete the continuation character. 7.2 Known Differences and Compatibility Between ZBasic and Visual Basic - VB implements run-time checks of various types including variable range overflow, array index bounds checking, stack overflow checking, etc. ZBasic checks string length only for allocated strings and fixed-length strings and has optional run-time stack overflow detection (for VM mode devices only). - VB does not directly support UnsignedInteger and UnsignedLong data types. You can add such support to VB using classes but even then the characteristics of objects make them inherently different than using a native type. - The VB behavior of “sign extending” hexadecimal values in the range &H8000 to &HFFFF (without the trailing ampersand) is not implemented (except in BasicX compatibility mode). This departure is implemented for compatibility with native unsigned types. - The exponentiation operator in ZBasic is more limited in the types that can be handled as compared to VB. Also, in ZBasic the exponentiation operator is right associative compared to being left associative in VB. Right associativity for exponentiation is both more natural and more common in other languages. - The only type designation characters recognized in ZBasic are the exclamation mark and pound sign. Both of these characters force type Single while in VB they force Single and Double respectively. ZBasic does not support type Double. Inasmuch as ZBasic may support Double types in the future, use of the pound sign type designator is strongly discouraged. Chapter 8