File Class

The File class enables you to read and write disk files, either sequentially or with random access. The following example shows the use of properties and methods defined in the File class.

loadCustomers();
vars
    file               : File;
    cust               : Customer;
    line, tName        : String;
    tAddress, tContact : String;
    company            : Company;
begin
    create file;
    file.fileName := "c:\data\customers.txt";
    file.kind     := File.Kind_Unknown_Text;
    file.mode     := File.Mode_Input;
    file.open;
    beginTransaction;
        while not file.endOfFile do
            line      := file.readLine;
            tName     := line[1:29].trimRight;
            tContact  := line [31:24].trimRight;
            tAddress  := line [56:end].trimRight;
            create cust;
            cust.loadSelf(company, tName, tAddress, tContact);
        endwhile;
    commitTransaction;
epilog
    delete file;
end;

You cannot create persistent instances of the File class.

If you need to create shared transient instances of the File class, note that as the implicit opening of a shared transient file updates the state within the file object, you must explicitly open a file inside a transient transaction, as shown in the following example.

constants
    FileName : String = 'c:\data\jade\MyTestFile.txt';
vars
    file : File;
begin
    beginTransientTransaction;
        create file sharedTransient;
        file.fileName := FileName;
        file.open;
        ...           // do some processing here
        file.close;
        delete file;
    commitTransientTransaction;
end;

In JADE thin client mode, instances of the File class refer to files on the presentation client when the FileNode class usePresentationFileSystem property is set to true and the instances are not shared transient instances. Shared transient instances of the File class are processed on the application server, and the setting of the usePresentationFileSystem property is ignored. (A file opened on one presentation client cannot be accessed by another client.)

For details about the constants, properties, and methods defined in the File class, see "File Class Constants", "File Properties", and "File Methods", in the following subsections.

FileNode

(None)