Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 32 Next »

Overview

PhixFlow is a low-code, application-development platform. Using PhixFlow, you can create applications starting with the user interface, rather than requiring software developers to code all the functionality. However, PhixFlow sometimes needs code-like instruction to achieve the dynamic behaviour you need. This is done using:

  • simple, short expressions
  • longer, more complex scripts
  • reusable macros.See Macro

PhixFlow items have a property tab where you set the options for that item. You can see a list of the help pages for different items on the Property Tabs page. Items where you may need to add some instructions have a field where you can enter an expression. These dynamic fields are often labelled as Expression.

Actions have a dynamic field where you can write an expression to check that the action has run correctly.


Streams have several dynamic fields where you affect the data records in the stream 

This topic explains how to write your own expressions, from simple assignments to complex looping operations.

Expression BasicsBasic operations (+, -, *, /), $-variables, variable types, assignment statements, object types and commenting scripts.
Expression StyleA summary of the recommend scripting styles e.g. how to lay out an if clause and how best to name variables etc
Using VariablesHow variables are used in PhixFlow.
PhixFlow Internal VariablesA list of values that PhixFlow defines in the course of processing that are available for use in building models.
Conditional StatementsHow to conditionally control the flow of your script using the if() and switch() functions.
Looping StatementsHow to execute blocks of script a number of times.
Arrays and Record SetsHandling sets of data.
Filters and LookupsHow to construct filters and perform dynamic lookups on Pipes.
MacroEncapsulate script so that it can be used from several different dynamic fields


Arguments

Arguments can contain several types of functions. (To find the correct syntax for an expression - find it in the list below or search in confluence)

  1. Another jep expression eg. if( _out.AppleHarvestDate < toDate('20210101'), 1, 0). Here we see an expression within an expression. toDate(converts the string 20210101 into a date 01-01-2021)
  2. Internal Variables (eg _out.) _out. signals that AppleHarvestDate is being sourced from the same stream as the attribute on which you are writing an expression for and that it has therefore already been calculated. Also frequently used is the name of a pipe that goes into a stream followed by a . eg in.AppleHarvestDate which signals that AppleHarvestDate is being sourced down a pipe going into the stream called 'in'. The internal variable preceding an attribute name should reflect where the attribute is being source from. There are many other internal variables, see Internal Variables.
  3. Regular Expressions - Regular expressions can be used to match patterns within strings or arrays as arguments within jep expressions, for example replaceAllreplaceFirst and matches. See Regexp ToDelete.
  4. Simple integers or strings. In the above case 1 and 0 are simple integers. They tell PhixFlow to return the number 1 if NumberOfApples > 1 and 0 if it is not. A string could be returned instead eg. if(_out.NumberOfApples > 1, 'True', 'False') would return the string True if NumberOfApples >1 and False if it is not. Note strings need to be wrapped in ' marks. 

Additionally it is good practise to add comments to code to allow other people to understand the code you have written. Comments are not evaluated when the code is run. To add a comment start a new line and begin it with */ and end it with */. 

eg. if(_out.AppleHarvestDate < toDate('20210101'), 1,

/* Evaluates to 1 if AppleHarvest Date is Before 1st January 2021*/

0

/* and to 0 if it is not */

)



The pages in this topic are:

  • No labels