49 of 208
ZBasic Language Reference 41 ZX Microcontroller Family Examples of String Literals: "" "Hello, world!" "The quick brown fox" & _ " jumped over the lazy dog." "Hello, ""Joe""!" The third and fourth lines above show how to use the concatenation operator and line continuation to construct longer strings. Note that the underscore must be the last character on the line and that there must be a space or tab character preceding it. The last example shows how to include a quotation mark within a string literal. Two consecutive quote marks are reduced to one in the actual string. If you want two adjacent quote marks in the string, you’ll have to double each of them. 2.6.5 Built-in Binary Constants Although they are technically not numeric literals, ZBasic provides some built-in Byte constants that serve the same purpose. The constants begin with the letters BX and are followed by exactly 8 binary digits (0-1). There may be an underscore between any pair of binary digits to enhance readability. These constants are of type Byte and may only be used where a Byte type is allowed. These built-in constants are supported for compatibility with BasicX. It is recommended that new applications use binary literals (described in Section 2.6.2) since they are more generally useful. Examples Bx0100_1101 BX01_00_11_01 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.