May 23, 2015

Parameters in EasyMorph



Project parameters appeared in EasyMorph starting from version 1.6. Parameters can be used in several cases:
  • File names in export/import transformations
  • Constants in expressions
  • Various transformation properties (e.g. number of rows, folder paths, etc.)
Parameters can be of several types:
  • Number / text -- this is simply a text, or number (if the entered value looks like a number).
  • File name -- this is the same as text, but with a file browser button added for convenience
  • Date -- it's a number with a date picker button added for convenience
  • Calculated parameter -- a parameter calculated using an expression. Since parameters are global for project referring to field names in parameter expressions makes no sense and therefore not allowed. As of version 1.6 it's not possible to refer in expressions to other calculated parameters, only to non-calculated ones. Although this limitation will be relaxed in future versions.
If field expressions, used in transformations like Calculate New Columns or Filter By Condition parameters can be referred using curly brackets (braces). In the example below Exchange rate is a parameter:

[Amount] * {Exchange rate}

In the expression editor parameters are available from a separate list:



Creating, editing and deleting parameters can be done from Parameter Editor which is available from menu Project or by pressing F6. Notice that depending on parameter type its input value box has different helper buttons:

For convenience, all non-calculated parameters are prompted on full runs -- i.e. when all project transformations have to be calculated (e.g. right after opening a project) or re-calculated (e.g. by pressing Reload and Run). Notice that parameter type can't be changed in Enter Parameters window.

When running a project from command line its parameters can be defined using /param option. Examples:

morph.exe /c /run /param:Year=2015 proj.morph

morph.exe /c /run /param:”File name”=“C:\My documents\file.csv” proj.morph


Parameter names and parameter values with spaces must be wrapped in double quotes. Special characters (if any) should be properly escaped. If a parameter is omitted then its default value is used. Calculated parameters can't be defined from command line.

There are numerous use cases for parameters in EasyMorph:
  • Input and output file names
  • Dates and file timestamps
  • Using single spreadsheet name when reading from several sheets of the same spreadsheet
  • Various ratios and multipliers in expressions (e.g. margins or exchange rates)
  • Flags that change calculation behavior (e.g. exclude or include some data)
Parameters is also a cornerstone for iterations (loops), where parameters of a project are linked to fields of a table in another project and then the first project is executed once per every line of that table.

Links: