The Number 1 independent website for ACL information!

TexasACL User Group
About Us
Training
Why ACL
Essays & Scripts
ACL News
Events
Links
FAQ
Site Map
Support Us
Occasionally when dealing with IT or other units, the client will provide a file without headers.  They will then provide a separate file with the file names.  The auditor then has to manually add those field names to each field.  This code automates that process.


Main Script

COM*****************************************************
COM Author: Porter Broyles
COM Date: July 1, 2008
COM Description:  This script is designed to add headers to a file that is missing the field names.
COM It assumes that the field names are preserved on a different table in the same order as
COM the fields on the table.
COM This script was uploaded to the TexasACL.COM website.
COM******************************************************

SET SAFETY OFF
DELETE ALL OK

DIALOG (DIALOG TITLE "User Dialog" WIDTH 649 HEIGHT 586 ) (BUTTONSET TITLE "&OK;&Cancel" AT 540 36 DEFAULT 1 ) (TEXT TITLE "Select table with the field data" AT 24 28 ) (ITEM TITLE "f" TO "T_Define" AT 192 24 WIDTH 322 HEIGHT 303 ) (TEXT TITLE "Select table with the field definitions" AT 24 64 ) (ITEM TITLE "f" TO "t_definition" AT 192 60 WIDTH 318 HEIGHT 299 )

OPEN %t_definition%

DIALOG (DIALOG TITLE "User Dialog" WIDTH 602 HEIGHT 478 ) (BUTTONSET TITLE "&OK;&Cancel" AT 504 24 DEFAULT 1 ) (TEXT TITLE "Select field with fieldname" AT 24 28 ) (ITEM TITLE "CND" TO "v_fieldname" AT 192 24 WIDTH 283 HEIGHT 309 )

COUNT if %v_fieldname% <> ""
v_cnt_ctrl = count1
v_cnt = 1
V_extract = blank(1000)

Do Script A02a_Define_fieldnames while v_cnt <= v_cnt_ctrl

EXTRACT FIELDS "%v_extract%" to %t_define%_1
SET SAFETY ON


Subscript: A02a_Define_fieldnames

Open %t_definition%

Locate record v_cnt

v_fieldname1 = %v_fieldname%

OPEN %t_define%

DELETE %v_fieldname1% OK

DEFINE FIELD %v_fieldname1% COMPUTED field_%v_cnt%

v_extract = ALL("%v_fieldname1%") + " " + ALL("%v_extract%")

v_cnt=v_cnt+1