446
Platforms
©2000-2008 Tibbo Technology Inc.
specified amount of bytes in the beginning of the file:
'open a file 'on' file number 4
fd.filenum=4
fd.open("SomeFile")
fd.setfilesize(fd.filesize/2)
'cut the file size in half
The fd.setfilesize can't be used to enlarge your file, only to make it smaller. Data
sectors previously allocated to the file will be "released" (marked unused) if they
become unnecessary due to the reduction in the file size. The first data sector of
the file, however, will always remain allocated, even when the file size is set to 0.
The size of the file, indicated by the
R/O property, will be corrected
downwards to reflect the amount of data left in the file.
will be affected by this method. If the file becomes empty,
the pointer will be set to 0. If the new file size is not zero, but the new size makes
current pointer position invalid (that is, fd.pointer > fd.f1) then the pointer
will be set to fd.f1.
The second method --
-- removes a specified number of sectors
(not bytes) from the beginning of the file and leaves the end portion of the file
intact:
'open a file 'on' file number 2
fd.filenum=2
fd.open("SomeFile")
fd.cutfromtop(3)
'remove three front sectors from the file (that is,
remove up to 3*256= 768 bytes of data)
The size of the file will be corrected downwards in accordance with the amount of
removed data. For example, performing fd.cutfromtop(2) on a file occupying 3
data sectors will reduce its size by 512 bytes (amount of data in 2 sectors
removed). Performing fd.cutfromtop(3) will set the file size to 0.
The pointer position is always reset as a result of this method execution. If the new
file size is 0, then the pointer will be set to 0 as well. If the file size is not 0, then
the pointer will be set to 1.
Searching Files
method allows you to quickly search through the file from a specified
starting position, either in forward or back direction, and locate the Nth instance of
a search substring. The method also allows you to specify the search
"increment" (step). The search is performed on a currently selected file, and the
selection is made through the
property.
The search returns the position within the file, counting from 1, where the target
occurrence of the substring has been encountered, or 0 if the target occurrence of
the substring was not found.
The increment parameter is very important as it allows you to perform two
fundamentally different classes of search.
Full text search
Set the increment to 1 and you will search through the entire contents of the file:
464
444
461
464
463