Arguments (argv variable)

The argv variable is a standard array field provided by the language to pass arguments into a script. It is predefined in all executions of the sil scripts

Where it is used

There may be situations where a single script is used in such a way that the argv variable is truly needed, so you may want to differentiate between calls:

 

Refer to each item documentation to see the parameters passed onto the argv variable

How to use it

Just like any other standard field, the argv variable can be called directly in any script. For example, the following script would print all the arguments in the argv variable in the log file.

logPrint("INFO", argv);

Since the argv variable is an array it can also work with index operators:

string firstArg = argv[0]; //or, provided that the invoking protocol defines a map array string summaryValue = argv["summary"];

Or, since the argv variable is an array it can be iterated over using a loop:

for(string argument in argv) { //do something with the value of the argument variable }

Examples

SIL Runner Gadget Example

While it is usually better to use a parameter script to create input fields, generic parameters can be used and passed to the script.

image-20240213-195106.png

The values of the parameters can be accessed using the argv variable:

Call function example

This script is designed to be used by the call() function as reusable code. It is a function that derives the file name from the full file path.

getFileName.sil - reusable function

Some other script

SIL Scheduler example

For this example we have a scheduled script that will check the weather for several US ZIP codes and create new issues with the weather information.

image-20240213-193037.png

The following code excerpt shows how the arguments can be iterated over to perform the action for each ZIP code:

 

 

 

Peacock