Versions Compared

Key

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

...

Note that if you want to assign a string value (as in the last example) then the characters must be enclosed in either single 'Hello' or double "Hello" quotes.

...

Parameter Types 
Anchor

...

paramTypes
paramTypes

When writing expressions it is important to consider the type of the result. For example, if you have written a Stream Attribute expression to return the integer 3 but have defined the type of the Stream Attribute to be a String then PhixFlow will stop and report the error when the expression is evaluated. The full list of types handled by PhixFlow is shown below. It's not necessary to understand the meaning of the individual types at this stage, however just be aware that the different types exist.

...

Often there is a need to work out the result of a more complex expression which may require several different statements to be evaluated first. To group several statements together in this way, you should make use of the do() function. In nearly all multiline statements, it is also very convenient to assign the value of an expression to a $-variable which may then be used later in the expression. E.g.

ExpressionResult

do (

    $name = in.customerName,

    $title = in.title,

    $salutation = "Dear",

    $result = $salutation + ' ' + $title + $name

)

"Dear Mr Smith"

Please note that every statement within the do() function (except the last) ends in a comma ",".

Please also note that the value of an expression (e.g. the value that will be assigned into a Stream Attribute ) is the value of the last statement to be evaluated. In the above example, this seems very trivial as the last statement to be evaluated is the last line. However when we look at Conditional Statements the last statement evaluated is not always the last statement in the expression. For  For example:


Expression
Result

if (

    in.customerName == "Smith",
    45 ,

// else

    36

)

45 if the customer's name is "Smith" but otherwise the value 36.


Adding Comments

In longer scripts (and even short scripts) it is a good idea to add comments to remind yourself (and anyone else who may need to modify the script in future) what steps are being followed. For short, 1 line comments, just prefix the line with // and for longer, multiline comments, enclose the lines in /* .... */. For example:

...