PhixFlow Help
Macro
For example, we want to reuse an expression:
if( out.AppleHarvestDate < 1, 1, 0)
Create a macro called isGreaterThanOne that contains the expression:
if($args[1] > 1, 1, 0)
To use the macro, replacing $arg[1]
with the pipe and attribute name _out.AppleHarvestDate
:
isGreaterThanOne(_out.AppleHarvestDate)
See also: Expressions and Scripts
Macro Properties
For information about the properties toolbar, and about the sections Parent Details, Analysis Models, Description and Audit Summary, see Common Properties. For a full list of all the PhixFlow property tabs and windows, see Property Tabs.
Basic Settings
Field | Description |
---|---|
Name | The name of the macro. This name is also how the macro will be invoked (called) from elsewhere in PhixFlow |
Minimum Parameters | The minumum number of parameters that must be passed to the macro when it is invoked. |
Maximum Parameters | The maximum number of parameters that may be passed to the macro when it is invoked. |
Expression
Field | Description |
---|---|
Expression | Enter the expression that evaluates to a value based on the input parameters. |
Example
Thie following macro is called padCost. It takes 1 parameter - a numeric value. It checks to see if the numeric value is missing a 0 before a decimal point. If so, it adds the 0 and returns the string. It can be called anywhere in PhixFlow that an expression can be entered. For example, by entering padCost(".977")
do( $val = $args[1], if( startsWith($val, "."), // if the cost is positive, add a zero onto the beginning "0" + $val, // ELSE if( startsWith($val, "-."), //if the cost is negative, replace the -. with a -0. "-0." + substring($val,3), //ELSE $val ) ) )
See also:
Please let us know if we could improve this page feedback@phixflow.com