Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

PhixFlow Variables

Introduction

PhixFlow has 3 different kinds of Variable which can be referenced in Attribute Expressions and other places where expressions are allowed. These are :

  • Internal Variables - These are variables that are created and populated by PhixFlow when certain actions happen. E.g. _fileName is populated by PhixFlow and is available in the definition of Stream attribute, when the streamset has data that is coming from a fileCollector. A full list of Internal Variables, and how they are populated can be found here.
  • User Defined Variables - These are variables that are defined by the user, and can be used to hold data required for complex calculations in attributes or other expressions.
  • Attribute Names - These are the attribute names that are defined as part of a Stream which are subsequently available for use in other attributes or expressions. Attributes can referred to in File Collectors, and implicit attribute names come from database collectors as a special case where these are the names of the fields returned by the DB Collector query. Attribute names can be qualified with pipe names e.g. pipename.recordID.

 

Defining a Variable

A User Defined Variable must start with the $ character. By convention, Camel case naming convention is used (Camel case is a convention where names are made up of multiple words, with no spaces and the first letter of each word is capitalised. e.g. ThisIsCamelCase) when giving a variable a name, and variables that are local to the current function or expression should start with a lower case letter after the initial $ character. Variables whose scope extends beyond the current attribute expressions should start with an upper case letter after the initial $ character.

...

$localVar = 'Smith' $GlobalVar = 'St.John-Smith'

Anchor
varType
varType
Variable Typing

When a variable is first used, PhixFlow will make a best guess about what type of data is stored in that variable. e.g.

...

will cause PhixFlow to reject the expression you are building. In some cases a Type Conversion function (e.g. toDate) can be used to force a value of one type, into a variable of another type.Note : in some cases, PhixFlow will be able to convert from one type to another. e.g. from an integer to a floating point value.

A further discussion of type assignments and full list of types is available in the Parameter Types section on the help page for Scripting Basics and a discussion on how complex expressions can be defined for attributes is available here.

Anchor
varScope
varScope
Variable Scoping

When writing expressions that reference variables it is important to understand the scope of those variables.

...

Note : Attributes are evaluated in order, so Variables defined in an Attribute (or the attribute name itself) can be referenced in a later Attribute Expression, or in a dependent Expression that is referenced after that Attribute is evaluated.
E.g. you can refer in a pipe index Expression to a $variable if you have done a “lookup($variable)� in the Stream before that pipe reference (or in an Output Multiplier, or an Output Filter), but otherwise you can’t.

 

The following tables gives some guidelines for the availability of Variables, based on the PhixFlow Timing Cycle for evaluating Models.

Location of ExpressionAvailable Variables
Input MultiplierSome Internal Variables (e.g. _toDate)
User Defined Variables (i.e. variables declared locally
in the Input Multiplier)
Database Collector SQL script_inputMultiplier
%USERNAME%, %PASSWORD%
User Defined Variables
Output MultiplierInternal Variables (e.g. _toDate)
User Defined Variables
Attribute ExpressionInternal Variables (e.g. _toDate)
All <pipeName> values (e.g. inpipe.accountVal
All _out.value where value is the name of the
attribute and it is before the current attribute
in the Stream
All user defined variables created in a
prior Attribute expression
Output Filter ExpressionInternal Variables (e.g. _toDate)
All _out.attribute values
All user defined variables created in any
Attribute expression
Pipe Index Expression on a
Lookup pipe
Internal Variables
<pipename>.attribute - the name on an input pipe
All _out.value where value is the name of the
attribute and it is before the current attribute
in the Stream
Alarm Generator ExpressionsInternal Variables
<pipename>.attribute - the name on an input pipe
Workflow TasksInternal Variables
<pipename>.attribute - the name on an input pipe that formed an input to the workflow

See Also