377
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
dim
w
as
word
dim
s
as
string
romfile.open(
"settings.txt"
)
if
romfile.size=
0
then
'File does not exist! Do something about it!
end
if
'look for the 'port' substring
w=romfile.find(
1
,
"Port"
,
1
)
if
w=
0
then
'Line not found- do something about it!
end
if
romfile.pointer=w
'set the pointer
'now look for the end of this line
w=romfile.find(w,chr(
13
),
1
)
'we assume that the CR (ASCII=13) will
definitely be encountered
'OK, now read
s=romfile.getdata(w-romfile.pointer)
's now contains desired line from the file <settings.txt>
...
...
Notice, that with the romfile object characters are counted from 1, not 0.
Sometimes, you will need to open the file not for the purpose of accessing it, but
for the purpose of passing a reference to this file to another object. Such reference
"pointer" is provided by the
read-only property.
8.3.7.1
.Find Method
Function:
Locates Nth instance of a substring within a currently
opened resource (ROM) file.
Syntax:
romfile.find(frompos as word, byref substr as string,
num as word) as word
Returns:
File position at which the substr resides or 0 if the desired
substring occurrence is not found
See Also:
Part
Description
frompos
Position in the ROM file from which the search will be
conducted (first character of the file is at position 1, if you
set this parameter to 0 it will be interpreted as 1).
substr
Substring to search for.
num
Instance number (occurrence) of the substring we are
looking for.
Details
378
375