Skip to content

runFromConfig

Run a function using arguments looked up from config tables.

runFromConfig(
    TableName,
    RowLookup="dynamicRowLookup",
    FunctionNameToRun,
    Arg1,
    Arg2,
    Arg3,
    ...
)

This should be used together with one or more of the following helper functions: - confFormula: A shorthand version of getFormulaFromConfig. - confValue: A shorthand version of getValueFromConfig.

Arguments

TableName
Name of the config table range. If this is a direct reference, it has to be in quotation marks (e.g. "t_Inputs").
RowLookup
Lookup string to determine the appropriate row index. Defaults to "dynamicRowLookup", which is explained here.
FunctionNameToRun
The function to run with the looked-up arguments.
Arg1, Arg2, Arg3, ...
The arguments to pass to FunctionNameToRun.

Examples

runFromConfig alone

Using runFromConfig without helper functions does not do much.

runFromConfig("Table1", "Row1", "functionToRun", "arg1", "arg2", ...)

This resolves to:

functionToRun("arg1", "arg2", ...)

The first two arguments are not used in this case. They are only used if one or more arguments to the runFromConfig function is confFormula or confValue.

runFromConfig with confFormula

Say there is a config table in the model workbook called Table1 with the following contents:

C D
A E G
B F H

The first row contains the column names, C and D. The first column contains the row names, A and B. The other cells contain strings, which will be interpreted as formulas in this example.

To use formula snippets from a config table inside runFromConfig, use the confFormula function:

runFromConfig(
  "Table1",
  "A",
  "func",
  confFormula("C"),
  confFormula("D"),
)

This resolves to:

func(
    getFormulaFromConfig("Table1", "A", "C"),
    getFormulaFromConfig("Table1", "A", "D"),
)

In turn, this resolves to:

func(E,G)

Note that here, E and G are used as formulas, not as string values. If you expected to get the value from the cell, see the next example.

runFromConfig with confValue

Using the same table as in the previous example.

To use values from a config table inside runFromConfig, use the confFormula function:

runFromConfig(
  "Table1",
  "A",
  "func",
  confValue("C"),
  confValue("D"),
)

This resolves to:

func(
    getValueFromConfig("Table1", "A", "C"),
    getValueFromConfig("Table1", "A", "D"),
)

In turn, this resolves to:

func("E","G")

Note that here, "E" and "G" are string values, not formulas. If you expected to use E and G as variable names, see the previous example.