h2s PowerHome formula function
Description
Decodes a hex-encoded string to its non hex-encoded form with option to save directly to a file 
Syntax
h2s ( as_input, as_file, ai_type )
Argument Description
as_input String. The hex-encoded data contained within a string. Ex: "54455354" which is the ANSI hex-encoded value for "TEST"
as_file String. The full path and filename that you want the decoded hex to be saved to. If not saving to a file use an empty string ""
ai_type Integer. The type of output to be returned by the function.  See Usage below.
Return value
String. Returns the decoded data as a string if the ai_type parameter is 0 or 1. For ai_types 2 thru 6, returns "*SUCCESS" if successful and "*ERROR" if an error occurs. 
Usage
Use this function to convert hex-encoded data back to its original format. If you use ai_type = 0, the function expects the encoded hex string to be in ANSI format (1 byte = 2 hex digits = 1 character). If you use ai_type = 1, the hex encoded string should be in UTF8 format (2 bytes = 4 hex digits = 1 character). You should not use ai_type 0 or 1 for binary encoded hex data. The following ai_type values are available: 
Examples
The following examples demonstrate typical syntax/usage for this function.
• h2s("54455354","",0) - Returns the string "TEST" 
• h2s("54455354","c:\powerhome\test.txt",2) - Appends the string "TEST" to the c:\powerhome\test.txt file
• h2s("5400650073007400","",1) This call will return the string "Test".
• h2s("5400650073007400","c:\output.txt",4) This call will create the file c:\output.txt with UTF8 encoding and write the string "Test" to it. The function will return "*SUCCESS" if succesful and will return "*ERROR" if it fails.