ACL Scripts

Many new ACL users overestimate the difficultly in developing simple ACL scripts.  I would agree with you if we were talking about IDEA scripts which require some knowledge of Visual Basic.  But, in my opinion a simple, ACL script which only performs commands that you have previously executed and want to execute again, is simple to create.

Assumption: you have performed an analysis and want to save it in a script so you can repeat it.

In this case, you already know what you have done, and it is already recorded in the log file.  This gives you the option of using three different approaches to creating the script: Copy the commands from the log file; set script recorder ON and repeat the commands; and set syntax capture ON and repeat the commands.  A further option – when a results file is created – is “Create Script from Table History”.  Each of these will be discussed in turn.

  1. Copy from the log. In the Overview window, click on the Log tab, and select the desired commands you wish to save in a script.  The log contains all commands issued while the current ACL project was open (some of my log file have 2-3 years worth of commands) and the results of these command.   Simply click on the boxes (check the boxes) of the commands you want to sae in a script; then right click and select “Save selected items” as a “Script”.  This will copy the commands to a new script which you can rename and name.  Note: be sure to uncheck the command in the log otherwise the next time you copy from the log these will be copied as well.

Note: additional commands can be copied to any script by checking the box in the log and selecting “Copy”; then opening the script where you want to copy the command and pasting (Cntl-V) into the script.

Advantages: any command that was issued can be saved in a script.  This includes, but is not limited to, IMPORT of data files; creation of expressions; and all commands including those that do not create a new file (e.g. Statistics, Index).

Disadvantages: you may have to search for the commands that you want to capture in a script, particularly if you executed the commands you wish to save over several days. Note: you can use Cntl-F to search the log file.

  1. Set script recorder ON. Under the menu item Tools, select “Set script Recorder On”.  This will cause ACL to start recording all commands you execute.  Note: an icon of the script with a pen writing on it will appears on the bottom left of the ACL window until you set recorder off.

Advantages: all commands issued will be executed and recorded.

Disadvantages: you have to know in advance what you want to do (or repeat commands that you already executed – which you could simply copy from the log). The commands are executed and copied to the new script, so if you are dealing with large files, you have to wait for the command to complete execution.  Any errors made will also be captured in the script.

  1. Set syntax capture ON. Open a new (or existing) script and click on the button on the top left (“Start Syntax Capture”).  Now any commands you manually perform will be written to the script – but not executed.

Advantages: you can capture syntax quickly – without having to wait for the command to actually execute.

Disadvantages: if you capture the syntax to create a file (e.g. Execute, Sort, Summarize, Duplicates) the command syntax will be captured but the file is not (yet) created).  This can make it difficult to capture the syntax for subsequent commands that need to use the newly created file (which doesn’t exist yet).  Also, commands like Statistics which create system variables that can be used by other commands (e.g. Stratify get the min and max values from Statistics) will not be executed so the system variables will not exist (yet) and the syntax capture will report an error (e.g. must specify min and max values).

  1. Create Script from Table History. This is probably the easiest method of creating a script- it only requires three clicks: Tools – Create Script from Table History – OK (to Save the script). If you perform a series of commands that (eventually) result in a final result file being created, and want to save all the necessary command to re-create this file in a script – this does it for you.  Even if you have created temporary/interim files (EXTRACT IF, SUMM and SORT again), all the steps (and interim files) will be save (created) when you run the script again.

Advantages: even if you issued the commands, which created the interim files, over several days the table history will contain the necessary commands.  Copy from Log may be more difficult because the commands would be scattered throughout t he log.  You also don’t have to remember and recapture your logic and the commands – they are already in the table history.

Disadvantages: the table history will not contain commands that did not create a file.  This includes: defining new fields, Indexes and Relate commands, Statistics or other analysis commands they even if the results were used to create the file (e.g. STATISTICS and then EXTRACT IF AMOUNT > HIGH1).

Concluding thoughts.  The creation of simple scripts is just that – simple.  However, while the approaches can be used individually, they can also be used in combination.  I often use a combination of the above approaches – copy from log when I produce results that are important/valuable; syntax capture when I want to write a script (manually) but am unsure of the exact syntax; from table history when I have results that I want to repeat; and script recorder when I know that I want to run a series of commands (STATISTICS, STRATIFY, and CLASSIFY on several fields) on a large file – but don’t want to wait for the command to run.

I encourage you to try each of the options using something like the commands below:

From log – run and copy these to a script

  • Open a file
  • Run statistics on a numeric field
  • Classify to a file
  • Select commands in log
  • Right click and save selected item as a script
  • Rename and Save script
  • Run script
  • Check log

Set Script recorder on and execute these commands

  • Tools > Set script recorder on
  • Open a file
  • Set filter Numeric field greater than a value
  • Extract view to file
  • Tools > Set script recorder off
  • Rename and Save script
  • Run script
  • Check Log

Syntax capture

  • Create new script
  • Set syntax capture on
  • Open file
  • Statistics on numeric field
  • Classify on field1 to screen
  • Classify of field2 to screen
  • Sort on field to new file
  • Name and Save Script
  • Run Script
  • Check log

Create Script from Table History

  • Open file
  • Extract IF numeric field > value
  • SUMM on field to temp OPEN
  • SORT on COUNT D to My_results OPEN
  • Select Tools > Create Script From Table History
  • Rename and Save Script
  • Run Script
  • Check Log

 

Final thoughts.  These are simple scripts, but can set you on a path that leads to more complex scripts.  If you are developing scripts for others, then you will likely need to build dialog boxes, set up a consistent processing environment, prompt the user for input, error check user input, run subscripts, etc.  But these basic approaches and techniques will serve you well and help to get you started.

Leave a Reply

Your email address will not be published.