OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Files and Directories 59<br />
An existing read-only status can be deleted with the following call:<br />
SetAttr("test.txt", 0)<br />
The date and time of the last amendment to a file are provided by the FileDateTime<br />
function. The date is formatted here in accordance with the country-specific settings used<br />
on the system.<br />
FileDateTime("test.txt") ' Provides date and time of the last file<br />
amendment.<br />
The FileLen function determines the length of a file in bytes (as long integer value).<br />
FileLen("test.txt") ' Provides the length of the file in bytes<br />
Writing and Reading Text Files<br />
<strong>OpenOffice</strong>.<strong>org</strong> Basic provides a whole range of methods for reading and writing files. The<br />
following explanations relate to working with text files (not text documents).<br />
Writing Text Files<br />
Before a text file is accessed, it must first be opened. To do this, a free file handle is<br />
needed, which clearly identifies the file for subsequent file access.<br />
The FreeFile function is used to create a free file handle. The handle is used as a parameter<br />
for the Open instruction, which opens the file. To open a file so that it can be specified as a<br />
text file, the Open call is:<br />
Open Filename For Output As #FileNo<br />
Filename is a string containing the name of the file. FileNo is the handle created by the<br />
FreeFile function.<br />
Once the file is opened, the Print instruction can be described line by line:<br />
Print #FileNo, "This is a test line."<br />
FileNo also stands for the file handle here. The second parameter specifies the text that is<br />
to be saved as a line of the text file.<br />
Once the writing process has been completed, the file must be closed using a Close call: