Page 60 of 229 Start Back Next End ZBasic Language Reference 50 ZBasic Microcontrollers Call d1.Source("mydata.txt") b = d1(2) End Sub Only one method of specifying the initialization data can be used for any particular Program Memory data item. Attempting to specify the initialization data multiple times will result in a compiler error even if the data supplied in the multiple cases is identical. 2.11 String Types ZBasic supports several variations of the fundamental type String. You may define a string variable thus: Dim msg as String The amount of space required for this variable definition and the maximum size of the string that it can represent varies depending compiler command line options and Option Directives. By default, the maximum string size is 255 characters. See Section 3.27 for more information on the implementation details of the various string data types. 2.11.1 Bounded Strings A bounded string is nothing more than a way to specify a string having a maximum length that may be different than the default string length. A bounded string is defined using the syntax: {Public | Private | Dim} <name> as [New] BoundedString(<size-expr>) When defining a bounded string, you replace the <size-expr> with a constant integral expression specifying the number of bytes to allocate for the string’s characters. Examples Const slen as Integer = 7 Dim msg as BoundedString(15) Dim msg as BoundedString(slen + 2) The first definition will create a string variable that can hold up to 15 characters; the second will hold 9 characters. For compatibility with BasicX, the alternate syntax shown below is also supported. New applications should use the definition syntax given above since it allows the use of an expression to specify the length. {Public | Private | Dim} <name> as New BoundedString_<length> 2.11.2 Fixed-Length Strings For compatibility with BasicX, ZBasic supports fixed-length strings. These are similar to bounded strings but with two important distinctions. Firstly, the string size is constant and equal to the specified fixed size. If a string value is assigned that has fewer characters than a fixed-length string variable’s specified size, the remaining characters will be filled with spaces. Secondly, if a string value is assigned having more characters than a fixed-length string’s specified size, the excess characters will be discarded. A fixed-length string is defined using the syntax: {Public | Private | Dim} <name> as [New] String * <size-expr>