Runtime Parameters

It’s sometimes helpful to provide a value for use in one of the conditional expressions at runtime rather than needing to edit the config file each time. For example, instead of hard-coding the date in the above filter, you might want to write something like:

Filter: "$EFF_DATE != nil && $EFF_DATE < Date(p1)"

Here, we’ve defined a parameter called “p1” which will hold the value we include on the run command. That might look something like:

loadsheets -config t2.yaml -highlight -params "p1=2020-01-01"

If you need to supply more than one parameter, simple separate them by a comma. For example:

loadsheets -config t2.yaml -highlight -params "p1=2020-01-01,p2='XYZ'"

See the section on “Writing Expressions” for more information.

SET /p Command (for user prompts):

Here is how to prompt the user for a value and pass it into the loadsheets program (for use in a filter expression).

set /p EXPDATE="Cutoff Date (yyyy-mm-dd): "
loadsheets -config t1.yaml -highlight -params "cutoff=%EXPDATE%"

The “EXPDATE” above could be any name (that is not already used as a variable). Note the use of it with %% around it in the -params phrase.

The actual variable, in this case, that is passed in is “cutoff” (you could make it p1, p2 or whatever you like). You would use the variable “cutoff” in the config file like this: Filter: “DateBefore($EFF_DATE, cutoff)“

Resulting log file:

loadsheets (v1.0.5)
...
Run Parameters: [cutoff=2021-01-01]
...
Warnings: 1, Elapsed time: 496ms
Revised: 2020-12-05