376
Platforms
©2000-2008 Tibbo Technology Inc.
be opened at any given time and there is no need to close it. The size of the file
you have opened can be checked through the
read-only property.
If you attempt to open a non-existent file its size will be returned as 0.
This is how you know that the file does not exist!
There is a file pointer, accessible through the
property. When
you (re)open the file the pointer is at file position 1 (first character in the file). You
read the data from the file using the
method. As you read from
the file, the pointer is moving- each time by the number of characters you've just
read out. You can also move the pointer to the new position by writing desired
value into the romfile.pointer property.
The pointer is a variable of word type, therefore, you can only access
up to 65534 bytes in each file. You can add larger files to the project
but only first 65534 bytes of each file will be accessible from your
application.
method is used to find desired substring in the resource file.
This allows you to organize quick search for the file portion you need, which is very
useful if you keep some table data in the resource file (again, you can only search
within first 65534 bytes of the file).
For example, supposing you have the following data in the file <settings.txt>:
IP,4,4,127.0.0.1
Port,0,65535,1001
Protocol,0,1,0
...
...
This sample data represents the list of settings (user-definable parameters) that
your program keeps somewhere in the non-volatile memory (i.e.
object).
Each line of the file describes the setting name, minimum value (length),
maximum value (length), and default value.
Now, supposing you need to extract the string describing the "Port" setting. Here is
the code:
379
379
378
377
380