Creating a DAL Script Library

You can also create libraries of DAL scripts as structured named subroutines. The libraries which contain these named subroutines are standard ASCII files.

You can create and maintain the libraries with any standard text file editor. If you use a word processor, just remember to save the file as an ASCII text file.

Note The calculation language you use within a library is exactly the same as the language you use in the Field Properties window.

The layout of the library is shown here. Each script in the file must begin with BeginSub and end with EndSub.

BeginSub SCRIPT1
* This script returns #x set to 2 if #x was equal to 1 on enter.
IF (#x = 1) THEN #x = 2;
END;
RETURN (#x);
EndSub
 
BeginSub Script2
* This script returns a negative one if #y was equal to 5.
if(#y = 5) then Return (-1);
end;
EndSub
 
BeginSub Parse
* Parse a word from the string "parse_it"
#position = FIND (parse_it, " ");
word  = SUB (parse_it, 1, (#position - 1) )
parse_it  = CUT (parse_it, 1, #position );
return;
EndSub

In this example, SCRIPT1 is the name of the first script, Script2 is the name of the second script, and so on.

SCRIPT1, Script2, and Parse are only names, you can use any name you want as long as it is not the name of a DAL reserved function, statement, or key word such CALL, FIND, IF, and so on. Also keep in mind:

BeginSub and EndSub must be paired per script. You must have a space between BeginSub and the script name. For more information on these functions see BeginSub and EndSub.

Using XDD to update section information

If you plan to use the XDD to update section information, keep in mind that DAL scripts stored in the data section should follow the requirements specified for data entry.

In Documaker Studio section (FAP) files, use a single semicolon (;) as the statement separator in your rule data.

If you are entering a script into the AFGJOB.JDT file — as a PreTransDAL or a PostTransDAL — use two colons (::) as the statement separator. For instance, if you write multiple DAL statements into the data area, you must use two colons (::) as your statement separator.

Loading a DAL library

Once a DAL library is loaded, you can reference the scripts in the library by name. You do not have to use CALL or CHAIN.

For example, assume the DAL library file, EXAMPLE.DAL contains the sub-routine functions on the previous page and the file has been loaded into cache memory using the following INI control group and options:

< DALLibraries >
Lib = example.dal
CompileWhenLoaded = Yes 

In this example, you reference the sub-routine function name directly: Script1( ) or Script2( ).

If ( @("multiphy_value") = " " Then
Return( Script1( ) )
Else
Return( Script2( ) )
End

You can execute SCRIPT1 or SCRIPT2 or neither after using the LoadLib function. For more information, see LoadLib.

Note You should only execute the LoadLib function once. You can execute the scripts in the library as many times as you wish.

For more information, see Using INI Options and LoadLib.