fileappend
PATH
,
DATA

The fileappend statement appends new data to an existing disk file.


Parameters

This statement has two parameters:

path – is a path to the file to be appended to, including the file name (see Files and Folders for more information about file paths).

data – is the actual data that will be placed into the file. This may be in a field, variable, or constructed with a formula. This parameter should be binary data. If the parameter is text, it will automatically be converted to binary data using UTF–8 (unicode) encoding. If you want to use a different encoding method you must use the texttobinary( function.


Description

This statement appends new data to an existing disk file. If the file does not already exist it will be created. If it does already exist the new data will be appended to the existing data. If you want to overwrite the existing contents of the file, use the filesave statement.

This example appends to a file named demo.txt in the Documents folder. The file contains the sentence Hello, this is a test.

fileappend "~/Documents/demo.txt","Hello, this is a test."

Each time the statement below is run, a new line will be added to the *test log.txt" file.

fileappend "~/Documents/test log.txt",timepattern(now(),"hh:mm:ss am/pm")+lf()

After running this statement a few times, the result will look like this:

12:35:33 am
12:36:07 am
12:36:11 am
12:36:14 am

The fileappend statement can work with any kind of file, but text files are the most common. If the data formula calculates a text value, the text will automatically be converted to binary data using UTF–8 (unicode) encoding. If you want to use a different encoding method you must use the texttobinary( function, as shown in this example:

fileappend "~/Documents/MyWebSite/index.html",
    texttobinary(timepattern(now(),"hh:mm:ss am/pm")+lf(),"ISO Latin")
Legacy Four Parameter Syntax

Previous versions of Panorama (version 6 and before) used a four parameter format for the fileappend statement:

fileappend folder,filename,typecreatorcode,data

For compatibility with existing databases, this format still works. Here is an example:

fileappend dbsubfolder("Logs"),datepattern(today(),"YYYYMMDD")+".log",TEXT    ",DataLogVariable

If the filename has an extension (.txt, .html, .css, .csv, etc.) then the typecreatorcode parameter is ignored (and you can leave it blank). If there is no extension, Panorama will add one based on the typecreatorcode supplied. For example, the code below will append to file named example.txt, not example.

fileappend dbfolder(),"example","TEXT    ",exampleTextVariable

The fileappend statement does NOT set the file’s OS 9 type/creator code. Current versions of Panorama only work with file extensions, not type/creator codes.


See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0 but now uses a 2 parameter syntax. (The old 4 parameter syntax is still available.)