50 of 172
ZBasic Language Reference 43 ZX Microcontroller Family ' 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) Caution: Program Memory data tables are arranged in memory in row-major order, i.e. the column values for the first row, followed by the column values of the second row, etc. This is a direct result of scanning the initialization data row by row. When you index a data table, you must specify the column index first and the row index second. This is backward with the respect to the way matrices are often visualized, i.e. (row, column). This strategy was adopted to maintain compatibility with BasicX. See Section 3.18 for more information on array data order.