Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

COMMENT

** DISCLAIMER NOTICE:
** ACL SERVICES LTD. ("ACL") AND ITS DISTRIBUTORS PROVIDE THE SCRIPT "AS
** IS" AND FREE OF CHARGE. ACL AND ITS DISTRIBUTORS: (A) DO NOT PROVIDE **
SUPPORT FOR THESE SCRIPTS; (B) MAKE NO WARRANTIES OR REPRESENTATIONS, **
EXPRESSED OR IMPLIED, WITH RESPECT TO THE SCRIPT, INCLUDING ITS FITNESS **
FOR A PARTICULAR PURPOSE, MERCHANTABILITY, DURABILITY, QUALITY OR ITS **
NON-INFRINGEMENT; (C) DO NOT WARRANT THAT THE SCRIPT IS FREE FROM **
ERRORS; AND (D) WILL NOT BE LIABLE FOR ANY DAMAGES(INCLUDING, BUT NOT **
LIMITED TO INDIRECT DAMAGES SUCH AS LOST PROFITS AND LOST DATA) ARISING **
OUT OF THE USE OF, OR THE INABILITY TO USE THE SCRIPT. YOU AGREE TO **
ASSUME ALL RISK OF LOSS OR DAMAGE ARISING FROM THE USE OF THE SCRIPT.
END

COMMENT
******************************************************************************
*
** Script Name: Append_multiple_data_files (Script 1 of 2)
** Description: This script prompts for the folder and file extensions of
** the files to append and a Table Layout name to use as the
** master template. ACL then calls GetFile script (Script 2).
**
** Requirements: Existing Table Layout used as a template to link all data
** files before appending the files. All files must be
** identical in structure and stored in the same folder. All
** files must have the same file extensions. The folder must
** not contain any files with the same file extension that
** are not part of the group of files to be appended.
**
** Output: A single data file with the combined records from all
** files.
**
** Written By: Thomas Steeves, ACL Services On: March 8, 2000
** Last Edit By: Tanja Klagge, ACL Services On: November 16, 2005
******************************************************************************
*
END

COMMENT
***** This will allow the script to overwrite previous results.

SET SAFETY OFF

CLOSE PRI SEC

DELETE ALL OK
DELETE "All_Records.FIL" OK
DELETE FORMAT All_Records OK

COMMENT
***** Prompt for the name of the template table to use for all data files.

DIALOG (DIALOG TITLE "ACL - Append Multiple Data Files" WIDTH 515 HEIGHT 263 )
(BUTTONSET TITLE "&OK;&Cancel" AT 408 180 DEFAULT 1 ) (TEXT TITLE "Select
Table Layout name of the master template" AT 12 40 ) (ITEM TITLE "f" TO
"v_table_name" AT 372 36 ) (TEXT TITLE "Enter the file extension of the files
to be appended, e.g. fil" AT 12 76 WIDTH 276 HEIGHT 14 ) (EDIT TO
"v_extension" AT 372 72 WIDTH 27 DEFAULT "fil" ) (TEXT TITLE "Enter the folder
that contains the files to be appended, e.g. c:\ACL Data" AT 12 112 WIDTH
345 ) (EDIT TO "v_folder" AT 372 108 DEFAULT "c:\ACL Data" )

COMMENT
***** Creates a listing of all files with the specified extension in a
specified directory.

DIR "%v_folder%\*.%v_extension%" TO Report_Names

COMMENT
***** Opens the Report_Names file.

OPEN Report_Names

COMMENT
***** Counts the number of entries in the Report_Names file.

COUNT

COMMENT
***** Initialize temporary variables to track the number of files selected
and their file names.

v_FileName= '"'+ALLTRIM(FILE_NAME)+'"'

COUNTER=COUNT1
V_REC=1

COMMENT
***** Do GetFile script once for each file to be appended.

DO GetFile WHILE V_REC <= COUNTER

COMMENT
***** Open the final output file.

OPEN All_Records

SET SAFETY ON
COMMENT
** DISCLAIMER NOTICE:
** ACL SERVICES LTD. ("ACL") AND ITS DISTRIBUTORS PROVIDE THE SCRIPT "AS
** IS" AND FREE OF CHARGE. ACL AND ITS DISTRIBUTORS: (A) DO NOT PROVIDE **
SUPPORT FOR THESE SCRIPTS; (B) MAKE NO WARRANTIES OR REPRESENTATIONS, **
EXPRESSED OR IMPLIED, WITH RESPECT TO THE SCRIPT, INCLUDING ITS FITNESS **
FOR A PARTICULAR PURPOSE, MERCHANTABILITY, DURABILITY, QUALITY OR ITS **
NON-INFRINGEMENT; (C) DO NOT WARRANT THAT THE SCRIPT IS FREE FROM **
ERRORS; AND (D) WILL NOT BE LIABLE FOR ANY DAMAGES(INCLUDING, BUT NOT **
LIMITED TO INDIRECT DAMAGES SUCH AS LOST PROFITS AND LOST DATA) ARISING **
OUT OF THE USE OF, OR THE INABILITY TO USE THE SCRIPT. YOU AGREE TO **
ASSUME ALL RISK OF LOSS OR DAMAGE ARISING FROM THE USE OF THE SCRIPT.
END

Comment
******************************************************************************
*
** Batch Name: GetFile (Batch 2)
** Description: This batch links a table layout to the selected data file.
**
** Requirements: Existing table layout used as a template to link all data
** files before appending the files.
**
** Output: A single data file with the combined records from all **
selected files.
** Written By: Thomas Steeves, ACL Services On: March 8, 2000
** Last Edit By: Tanja Klagge, ACL Services On: November 16, 2005
******************************************************************************
*
END

Comment
***** Select the correct filename from the temporary file.

LOCATE RECORD V_REC


v_FileName= '"'+ALLTRIM(FILE_NAME)+'"'

OPEN %v_FileName% FORMAT %v_table_name%

Comment
***** Extract and append all records to a new file called All_Records.

EXTRACT FIELDS ALL TO "All_Records" APPEND

Comment
***** Increase counter for next file.

ASSIGN V_REC = V_REC + 1

OPEN Report_Names

You might also like