Include Files are simply text files that contain individual small blocks of script that form functions and procedures that supplement the core code. These are particularly useful where the same custom procedure or function will be called in multiple instances, but where any necessary changes to the code only needs to be made once (to the code within the Include File) to affect all of those instances.

Include Files can either be created and defined here within the configuration and are only able to be used in that configuration, or they can be stored as a file on disk.

Files stored on disk have an .INC extension. An Include File that is stored as a file on disk can be accessed by any configuration script in any environment that has access to that disk and that file.

File-based Include Files can be edited with a simple text editor.

However, the danger for file-based Include Files is that they can be forgotten during the backup process. And because they can be accessed by different environments, any change to the code on an Include File that may be being used in several configurations or environments will impact all those configurations and environments, This could potentially have unintended consequences to those other configurations.

To create new Include Files for the configuration, right-click on Include Files and click New.

Any Include Files created will be listed under this section on the tree structure.

Include Files can also be referred to as Scripting Files.

Essentially, inserting an Include File into a script is called a run-time paste. where the text inside the file is pasted into the script at that point.

The format for calling an include file is {$I <filename>}, where $I indicates an Include File and <filename> is the name of the Include File, enclosed in a pair of braces { }. There must be a blank space after the compiler directive of $I - this is shorthand for $Include.

The format for calling an Include File uses braces { }, which in script is indicative of a comment that should be ignored. However, when the braces are immediately followed by $I, the script engine interprets this an instruction for accessing and using the code within the specified Include File.

Because you cannot use any reference before it has been declared, and this must obviously be done before its first use, the compiler command is always entered and defined in the very first top line of a script above any default script or following code.

As illustrated below, the code for declaring this Include File called Hello in the script is {$I Hello}, using braces to encase the code.

{$I Hello}
procedure LinkedDataEvent(var LinkedData:TdaQueryDataView); //SUPPLIERS
begin
LinkedData := CR_ACCS;
end;

As below, the filename must include the path if it is held on disk.

{$I C:\SL\Includes\Hello}
procedure LinkedDataEvent(var LinkedData:TdaQueryDataView); //SUPPLIERS
begin
LinkedData := CR_ACCS;
end;

Within the configuration, the Include File is shown in the structure tree as below.

The input screen is designed to resemble a mini Map script or Custom Script window. There are three (3) main sections - Parameters, Scripting, and Compiler.

image-20240311-031927.png

Fields

Field Name

Description

Include File Name

Replace the default name with a friendly and easily recognizable name given to the Include File.

Buttons

Button Name

Description

Save

Click Save to save the current Include File.

Cancel

Click Cancel to ignore any input and Cancel the input for the Include File.

Include Files can hold multiple pieces of code. The sample Include File that follows, called Converting Them, contains several simple scripts - one (1) procedure and two (2) functions.

image-20240305-014058.png