Phantom Documentation

[Help Home] [Phantom Home]
file

The file data type is used as a handle to access files. The file handle is set using the OpenFile function. Once the file is open, it can be used to access a file using WriteFile, ReadFile, and ReadAllFile. When a script is finished with a file, CloseFile should be called.

The file data type supports the following member functions:

GetStatus

Example Code

# Open a sample text file
file f = OpenFile("sample.txt", "w");

# Display OPEN WRITE status
disp(f.GetStatus());

# Wriite some lines of text
WriteFile(f, "Line 1...");
WriteFile(f, "Line 2...");

# Close the file
CloseFile(f);

# Display the closed status
disp(f.GetStatus());

# Open the file again for reading
f = OpenFile("sample.txt", "r");

# Display the OPEN READ status
disp(f.GetStatus());

# Read all of the text and display it
string s = ReadAllFile(f);
disp(s);

# Now f is at End Of File
# Display the OPEN READ EOF status
disp(f.GetStatus());

# Close the file
CloseFile(f);


Output
{OK}{OPEN}{WRITE}
{OK}{CLOSED}
{OK}{OPEN}{READ}
Line 1...
Line 2...

{OK}{OPEN}{READ}{EOF}



For additional information and examples, see File Operations.

See Also: CaptureBitmap, Variables


Copyright 2000-2011 Phantom Automated Solutions