Copyright David Revill Jan 2003 ------------------------------- UDF_File.dll Contains a set uf external functions for Interbase which provides basic external file handling, create, write, delete, copy, merge; Useful for the creation of external text file logs of data input, or the creation of static HTML pages from databases. ***************************** It is provided free subject to the conditions contained within the file Licence.txt included with the zip file. Any problems and queries should be addressed to Datarun@btclick.com ... we will do our best to resolve them ***************************** WARNING ***************************** The functions and procedures within the DLL can write,delete and create files on your server. It is the system managers responsibility to ensure that users cannot do any damage to the server as a result of these functions ! ******** CONTENTS ******** UDF_File.DLL UDF_File.sql - contains the external declarations and sample procedures. README.TXT - this file. Licence.txt - the terms under which the software is supplied. *************** In UDF_File.DLL *************** File_write ---------- Takes two parameters, the filename and the string value to be written. Creates the file ,if it does not exist, or appends if it does. File_writeln ------------ Takes two parameters, the filename and the string value to be written. Writes the string to the file and appends a carriage return line feed pair. Creates the file ,if it does not exist, or appends if it does. File_delete ----------- Deletes an external file File_create ----------- Creates and empty external file, overwriting any old one of the same name File_concat ----------- Concatenates one or more files into one destination file Takes two parameters, a comma separated list of source file names, and a destination file name. Useful for creating output files with header,detail and footer sections, or for simply copying files File_rename ----------- Takes two parameters, the old file name and the new file name Strformat --------- Creates a formatted string for output. Takes two parameters , the mask and the output string. Returns a string of the result. The mask is in the form of 'Field1= % field2= %' where the % marks the position of data from the output string. The output string should be in the form of a comma separated list of values. The file handling functions return an integer value to denote success or failure 0 Success 2 File not found. 3 Invalid file name. 4 Too many open files. 5 Access denied. 100 EOF. 101 Disk full. 106 Invalid input. -1 Other Error Nonull ------ Returns an empty string if a null value passed in parameter. Useful when a concatenating fields, where a single null value will return a null result for the result Dateformat ---------- Formats a timestamp in the second paramter according to the mask in the first parameter for example Dateformat('dd/mm/yy',createdate) - 12/01/03 Dateformat('dd mmm yyyy',createdate) - 12 Jan 2003 Numberformat ------------ Formats a number in the second paramter according to the mask in the first parameter for example Numberformat('0.00',2.1) - 2.10 Numberformat('$0.00',2.1) - $2.10 Squotedstr ---------- Returns a string surrounded by single quotes Dquotedstr ---------- Returns a string surrounded by Double quotes Padleft ------- Left pads a string with spaces to a fixed width (and truncates if too large) Padright -------- Left pads a string with spaces to a fixed width (and truncates if too large) *************** In UDF_File.sql *************** Declarations for the above external functions and definitions for stored procedures. procedure Fileconcat(sourcefiles varchar(1024),destfile varchar(255)) returns (res integer) procedure Filedelete(filename varchar(255)) returns (res integer) procedure Filecreate(filename varchar(255)) returns (res integer) procedure Filerename(oldfilename varchar(255),newfilename varchar(255)) returns (res integer) PROCEDURE DUMP_ASHTML(afilename varchar(255) - example of function use to create dump of procedures and tables to HTML File. ************ Installation ************ Copy the file UDF_File.dll to your Interbase UDF Directory ( Usually c:\program Files\borland\Interbase\UDF ) Run the script UDF_file.sql against your database to register the definitions ------------ David Revill Jan 2003 ------------