Start Back Next End
  
ZBasic Language Reference
49
ZBasic Microcontrollers
The second method to provide initialization data is to use an in-line initializer that consists of a pair of
curly braces bracketing the initialization data itself.  The form of the in-line initializer data is essentially the
same as the content of the initialization file described above but appearing between curly braces directly
in your source file.
Here is an example of the content of an initialization file for a ByteVectorData type:
' this is a data file
&H55
2
' comment
3
4, 5
   ' another comment
5,
&Haa
Below is an example of the initialization data for a SingleTableData type:
.30103,
3.14159 ' log of 2 and pi
-200.,
1e05
+6.02E+23
100
Here are examples of in-line initializers for one-dimensional and two-dimensional types.
Dim d1 as ByteVectorData({ 20, &Hff, &H20, "row" })
Dim strList as StringVectorData({
"alpha", "bravo", "charlie", "delta", "echo", "fox" + &H5f + "trot"
})
Dim tbl as New SingleTableData({
'
column 1
column 2
.30103,
3.14159
-200.,
1e05
+6.02E+23,
100
})
The values specified in an in-line initializer may be literal constants as shown above or they may be
named constants that are visible within the module.  For example,
Const cval as Byte = &H20
Dim d1 as ByteVectorData({ 20, &Hff, cval, "row" })
Program Memory data items have an associated property named DataAddress.  The value of this
property is the address of the data item in Program Memory.  The type of the property is Long for
compatibility with BasicX and the GetProgMem() subroutine.  
Example
Dim addr as Long
addr = tbl.DataAddress
It is possible, also, to use the DataAddress property to get the address of a particular Program Memory
data item.  To accomplish this, simply add parentheses following the property name and specify the index
or indices of the item of interest.  The example below will result in addr having the Program Memory
address of the second data value of the first row of the table.
addr = tbl.DataAddress(2, 1)
Previous page Top Next page