21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Files and Directories 57<br />

If the directory contains sub-directories or files, these are also deleted. You should<br />

therefore be careful when using RmDir.<br />

In VBA, the MkDir and RmDir functions only relate to the current directory. In <strong>OpenOffice</strong>.<strong>org</strong> Basic on<br />

the other hand, MkDir and RmDir can be used to create or delete levels of directories.<br />

In VBA, RmDir produces an error message if a directory contains a file. In <strong>OpenOffice</strong>.<strong>org</strong> Basic, the<br />

directory and all its files are deleted. If you use the CompatibilityMode ( true ) function,<br />

<strong>OpenOffice</strong>.<strong>org</strong> Basic will behave like VBA.<br />

Copying, Renaming, Deleting and Checking the Existence of Files<br />

The following call creates a copy of the Source file under the name of Destination:<br />

FileCopy(Source, Destination)<br />

With the help of the following function you can rename the OldName file with NewName.<br />

The As keyword syntax, and the fact that a comma is not used, goes back to the roots of the<br />

Basic language.<br />

Name OldName As NewName<br />

The following call deletes the Filename file. If you want to delete directory (including its<br />

files) use the RmDir function.<br />

Kill(Filename)<br />

The FileExists function can be used to check whether a file exists:<br />

If FileExists(Filename) Then<br />

MsgBox "file exists."<br />

End If

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!