• Reference Guide

File and Internet Functions

The function described here serve to access data stored in files and in the internet. In order to access a file or the internet, it is first necessary to create a variable of the type File:
var File f;
A real file is attached to the variable using the open function:
f <- open("c:\name.txt");
Alternatively, a new file can be created using the create function:
f <- create("c:\new.txt");
An internet resource is handled analogously. The only difference is in using the open_url function, instead:
f <- open_url("http://www.diotima.eu");
Data can be read from an open file using one of the read_... functions. To write data, one of the write_... functions can be used. The variable of the type File maintains a pointer to the file, which tracks the position at that the data are to be read/written. The position of the pointer can be obtained using the get_pos function and changed with the set_pos function.
When the manipulation with the file is finished, it should be closed with the close function:
f <- close;
If it is necessary to handle possible errors occurring during the manipulation with the file, the best way is to use the try statement.
Information about the standard folders, where documents are stored, can be obtained from the structure system.info.folders.


For some operations on folder and files, there are no appropriate functions defined. However, the standard OLE object FileSystemObject can be used. For an example, see the introduction of the chapter OLE objects.