open( ) example
The following example writes the current date and time to a text file, which you might do for a simple access log. The file is archived and deleted at the end of the week, so you need to test for its existence to determine whether it should be created or opened. The name of the file, which is used in three different places, is set in a manifest constant created by the #define preprocessor directive for ease of maintenance.
#define LOG_FILE "ACCESS.TXT"
f = new File()
if f.exists(LOG_FILE)
f.open(LOG_FILE, "A")
else
f.create(LOG_FILE, "A")
endif
f.puts(new Date().toLocaleString())
f.close()