46 of 172
ZBasic Language Reference 39 ZX Microcontroller Family 2.7 Comments Comments may be placed on a line by themselves or at the end of a line containing other program text. A comment begins with an apostrophe and continues to the end of the line. A comment may be continued on the next line in the manner described in Section 2.8. Note: The BasicX compiler does not allow comments to be continued but Visual Basic does. ZBasic allows comment continuation both in native mode and in BasicX compatibility mode. Examples 'This is a comment. a = 23 ' this is a comment, too b = 55 ' and because this comment ends with an underscore _ it continues on the next line 2.8 Line Continuation and Multiple Statements Per Line A statement may continued across multiple lines by ending each line except that last with an underscore preceded by at least one space or tab character. Except for spaces, tabs and/or a comment, no characters other than end-of-line characters may follow the underscore for it to be considered a line continuation character. The maximum aggregate size of a line, whether continued across multiple lines or not, is 1000 characters. In the example below the beginning of the If statement is continued to the following line. This is often useful to help make more complex expressions more readable. Example If (GetPin(20) = 1) And _ (GetPin(12) = 0) Then Call PutPin(5, 0) End If While the line continuation capability allows you to create statements that span multiple lines, it is sometimes convenient to place multiple statements on one line. In ZBasic, as in many other Basic dialects, you may accomplish this by using a colon to separate each pair of statements on the line. Example Dim i as Integer Dim j as Integer, k as Byte i = 0 : j = 1 : k = 2 2.9 Persistent Variables You may define variables that are stored in the processor’s internal EEPROM, referred to in this document as Persistent Memory. It is called persistent because the values that you store there are retained even if the system is powered down or reset. This characteristic makes persistent variables useful for storing configuration information for your application and other similar information that your application needs to be preserved. A persistent variable is defined at the module level using the syntax: {Public | Private | Dim} <name> as Persistent <type>