46 of 158
40 PersistentBoolean PersistentByte PersistentInteger PersistentLong PersistentSingle BasicX Compatibility Note In BasicX mode, all persistent variables must be defined at the module level and neither arrays nor structures of persistent variables are supported. Also, the DataAddress property cannot be used to determine the address of a persistent variable. 2.10 Program Memory Data Items It is often useful to have available initialized arrays of data that are stored in Program Memory. This is advantageous for two reasons. Firstly, you don’t need run-time code to initialize the arrays and, secondly, you don’t use up the more scarce RAM space for data that seldom, if ever, changes. You define an initialized Program Memory data item in a manner similar to the way that you define RAM- based data items. There are two differences, however. Firstly, you need to specify a data source from which the array is initialized. Secondly, you don’t explicitly specify the array dimensions. Instead, the dimensions are deduced from the content of the initialization data and the lower bound of each index is always 1. The definition syntax for a Program Memory data item is: {Public | Private | Dim} <name> as [New] <progmem-type>(<init-data>) For Program Memory data items defined within a subroutine or function, the Public and Private keywords are disallowed because they would serve no useful purpose. The supported <progmem-type> items are: One-dimensional types (vector types): ByteVectorData ByteVectorDataRW IntegerVectorData IntegerVectorDataRW LongVectorData LongVectorDataRW SingleVectorData SingleVectorDataRW StringVectorData Two-dimensional types (table types): ByteTableData ByteTableDataRW IntegerTableData IntegerTableDataRW LongTableData LongTableDataRW SingleTableData SingleTableDataRW StringTableData The types ending with RW may be both read and written while the remaining types can read but they cannot have values assigned to them. (Of course, you can still modify the read-only types by using the System Library routine PutProgMem() but this is generally only used for special circumstances.) The initialization data may be provided in two ways. The first way is to provide a file name, enclosed in quote marks, as the <init-data> element in the syntax description above. If the filename is not specified using an absolute path (i.e. beginning with the root directory and/or a drive letter), the path prefix (if any) of the current module is appended to the front of the filename. Note, however, that if an include path is specified on the command line, a filename that is specified with a relative path will, instead, be sought in among the directories specified in the include path list. See Section 7.2 for more information on the include path option. The content of the file should be a textual representation of the initialization data. For integral types, the data values may be expressed in decimal, in hexadecimal (using a &H or &h prefix), or in binary (using a