PhixFlow is a low code application development platform which allows applications to be build within a development user interface instead of being coded from the ground up by software developers. However, there are still places within PhixFlow where coding to achieve a function is needed in the form of expressions.
Jep Expressions are software commands which perform a function within PhixFlow. Expressions are written in camelCase without spaces, and with the first word lower case and subsequent words uppercase eg. listToString(). Expressions contain brackets in which a set of arguments are written separated by commas. The below list contains a list of pages on expressions, which give their correct syntax. However, a simple example is an if() statement.
if(_out.NumberOfApples > 1, 1, 0)
The syntax of an 'if' statement is if(condition, trueExpression, falseExpression), so in the expression above, _out.NumberOfApplies, 1 and 0 are the three arguments.
Arguments can contain several types of functions
- 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)
- An Internal Variables (eg _out.) _out. signals that AppleHarvestDate is being sourced from the same stream you are writing the expression on and that it has 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.
- Regular Expressions - Regular expressions can be used to match patterns within strings or arrays as arguments within jep expressions, for example replaceAll, replaceFirst and matches. See Regular Expressions.
- 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.
Additionally it is good practise to add comments to code to allow other people to understand it. 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 *\.
Macros
Sometimes we might want to write our own expressions that can be used time and again. To do this we can write a Macro. Instead of a writing the name of each attribute in the expression, instead we make it generic writing $args[1], $args[2] etc.
For example we could write a Macro called isGreaterThanOne with the expression if($args[1] > 1, 1, 0). Then instead of writing if( out.AppleHarvestDate < toDate('20210101'), 1, 0) we could write isGreaterThanOne(_out.AppleHarvestDate). Where _out.AppleHarvestDate is set to be $args[1] in this case. If what ever $args[1] is set to be is > 1 it will return 1 else it will return 0.
The pages in this topic are: