Navigation bar
  Start Previous page
 47 of 156 
Next page End 42 43 44 45 46 47 48 49 50 51 52  

41
BasicX Compatibility Note
In BasicX mode, Program Memory string types are not supported nor are any vector types other
than the Byte types.  Also, in-line initializers are not supported, the DataAddress property
cannot be used to determine the address of an individual Program Memory data element, and
quoted strings cannot be used to specify data values.  Finally, Program Memory data items may
only be defined at the module level.
You may completely omit the initialization data from the definition of a Program Memory data item,
including the parentheses that normally enclose it.  If you do this, you must use the Source method to
specify the initialization data as shown below.  This alternate initialization mechanism is supported for
backward compatibility with BasicX and is not recommended for new applications.  Note, particularly, that
this somewhat odd construction involving a Call does not produce any run-time executable code.  It is
merely a signal to the compiler to read the initialization data from the specified file.
Dim d1 as New ByteVectorData
Sub Main()
Dim b as Byte
' specify the initialization data
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
thusly:
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.26 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)
Previous page Top Next page