ph_writefile PowerHome formula function
Description
Writes data to the specified file
Syntax
ph_writefile ( as_filename, ai_writemode, as_data )
ph_writefile ( as_filename, ai_writemode, as_data, ai_type )
Argument Description
as_filename String. A string representing the path and filename of the file you wish to write to
ai_writemode Integer. An integer representing how you wish to write to the file. A value of 0 will append the data to the file, any other value will cause the file to be overwritten
as_data String. A string representing the data you wish to write to the file
ai_type Integer (Optional). Specified the type of data that is contained within as_data. If 0, the data is assumed to be standard string data and will be written to the file as is. Any other value means that as_data contains a hex encoded string that will first be decoded and then the results will be written to the specified file. If this parameter is omitted, a value of 0 is assumed
Return value
Integer. Returns a 0 if successful. Returns a 1 if an error occurred while opening the file
Usage
Use this function to write data to a file. If the file does not exist, it will first be created. You can write binary data to a file by representing it as a hex encoded string and using an ai_type value other than 0 
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_writefile("c:\powerhome\logs\log.txt",0,string(datetime(today(),now())) + ":" + ph_getvar_s(1,1) + "~r~n") - Appends the current date and time along with the data contained in [LOCAL1] to the c:\powerhome\logs\log.txt file 
• ph_writefile("c:\powerhome\test.txt",1,"54455354",1) - Overwrites or creates the file c:\powerhome\test.txt and writes the string TEST to the file