The feFile class provides generic file loading and saving.
It allows any file to be loaded from disk into memory, and any data in
memory to be saved to a file. Both saving and loading can be done by calling
a one method - feFile.Load() and feFile.Save() respectively.
The feFile class provides a simple mechanism for loading
and saving files to and from disk.
Using the feFile Class is very simple:
htmlFile class(feFile)
end
code
if not htmlFile.Load(fileName)
Message('
Load', '
Loading the file failed.')
end
htmlFile.Save(fileName)
When errors occur the methods call the
ErrorTrap() method with the warning or error. This allows the error to be
handled, and by default will log the error the the system debug output.
To display ErrorTrap messages set
the .
logging property of the class to 1 and the .
level property to the level of
logging required (0 for errors only, 1 to include warnings and 2 for all
messages including errors, warnings and information). The output can then be
viewed using the free DebugView utility from Microsoft (
www.sysinternals.com).
ErrorTrap
ErrorTrap (string errorMesssage, string methodName, long level=0)
Description
The ErrorTrap() method is called each time an error occurs,
or a warning is issued, or there is additional information available that can be
helpful for debugging and diagnostic purposes. The Level parameter is set
dependant on the type of message. The .
logging property
of the class determines whether these messages are logged to the system debug
output (.
logging =1) and the .
level
property of the class determines which messages are logged (.
level=0
logs only errors, .
level=1 logs errors and warnings, .
level=2
logs all messages.
Parameters
Parameter |
Description |
errorMessage | The text of the error, warning or informational message. |
methodName | The name of the method that called ErrorTrap. |
level |
The level of the of message, indicating the type of message that this is:
- level = 0, indicates that this is an Error message
- level = 2, indicates that this is a Warning message
- level = 3, indicates that this is an informational message.
|
Notes
The passed
level parameter is checked against
the .level property of the class. If the
level is passed is less
than or equal to .
level the error is logged (if the .
logging
property is set to a no zero value). By default the .
level
property is zero, and hence only error messages are logged. To also log
warning messages set .
logging to 1 and to log all
messages set .
logging to 2.
Cleanup
Cleanup ()
Description
Cleans up, deallocates all memory, and disposes of all
interfaces. Typically this will be called automatically by the destructor,
however if you are using New() and Dispose() to dynamically create and destroy
the object you should call Cleanup() before calling Dispose().
Load
Load (string fileName)
Description
Loads the specified file into memory. The contents of the
string are stored in the .binData property and the length of the data is stored
in the .binDataLen property.
Save
Save (string CurrentPath, long CurrentControl)
Description
This method is deprecated,
use the
#Load() method.
FileNameFromPath
FileNameFromPath (string fileName)
Description
Returns just the name of the file, when passed the
entire file path and name.
For example if 'C:\Temp\foo.txt'
was passed this method would return 'foo.txt'
PathOnly
PathOnly (string fileName)
Returns just the path when passed the entire file path and name.
For example if 'C:\Temp\foo.txt'
was passed, this method would return 'C:\temp\'