Using the Loop Control Node
There are multiple ways to use the Loop Control Node. You can choose what list of items your node is using for its loop, parameters to further define your input, and patterns that filter input to avoid looping on unintended items. Every loop requires parameters, which are defined in the processes that run during the loop and originate from locations defined in the Loop Control Node itself. When a parameter is defined in the Loop Control Node, it is accessible in all nodes that run in that loop. There are three ways to define where your parameters come from and an example of how to use each one follows.
Manually-defined parameters are static parameters that you list in the Loop Control Node. They do not change automatically between script runs and must be changed by a user. In the following example the loop runs with two manually-defined parameters.
For each row in the parameter table the loop uses the values for each column wherever you choose to enter the parameter . For this example, the Filepath and Filename parameters are used to construct source and destination files for a Copy Process Node.
Figure 2
Based on the parameter values from Figure 1 , the results of each loop are:
-
Source—/data/test/test.txt and Destination—/temp/test.txt
-
Source—/data/csv/test.csv and Destination—/temp/test.csv
Parameters derived from a parameter file are formatted with a header line and parameter lines. As such, a file formatted with table on the first line will have table be the name of the parameter that nodes within the loop can use. In the following example, a parameter file named Table_List.txt contains three names for Spectre build files (missing the .build extension).
For each row in the parameter table the loop uses the values for each column wherever you choose to enter the parameter. For this example, the table parameters are inserted into the filepath for existing Spectre build scripts that build cBases.
Figure 2
Based on the parameter values from Figure 1, the results of each loop are:
-
Build script—/programs/accounts.build
-
Build script—/programs/charges.build
-
Build script—/programs/diagnosis.build
You can define a series of files as sources for parameters using this option. Notably, this option does not involve the contents of any files. Rather, the parameters come from file metadata: the name of the file, the file path, the file size, and more. All potential parameters are listed in this table:
Parameter | Description |
---|---|
$_filename | Returns the name of the file (including extension). |
$_path | Returns the name of the file (including extension) and the file path that leads to it. |
$_extension | Returns the file extension. |
$_filesize | Returns the file size in bytes. |
$_modification_date | Returns the last date and time the file was modified. Formatted as YYYY/MM/DD hh:mm:ss. |
$_hidden | Returns if the file is hidden, as defined in the file properties. |
In the following example, the contents of the /data/transactions folder are copied to the /temp folder using a file loop pattern to get the file paths for each source file. A wildcard character (*) is used to signify that all csv files are to be looped through.
Figure 1
When using a file loop pattern, parameters are not available for editing as they are limited only to the values shown in the preceding table. For this example, three files in the /data/transactions folder is a parameter in the loop. The accounts_final.txt file is not a parameter as it is not a .csv file.
Figure 2
Figure 3
Based on three files in the folder, the results of each loop are:
-
Source—/data/transactions/accounts.csv and Destination—/temp/accounts.csv
-
Source—/data/transactions/charges.csv and Destination—/temp/charges.csv
-
Source—/data/transactions/diagnosis.csv and Destination—/temp/diagnosis.csv