Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
Overview
PhixFlow is a low-code, application-development platform
...
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 expression pages, which give their correct syntax. For example,
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:
...
. 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 expressions. Usually these are simple, short pieces of code. Longer, complex expressions are usually called scripts. For useful expressions that you want to reuse in different places, you can put the expression into a 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 Properties, Windows, Menus and Toolbars 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.
Usually a dynamic field is expecting an expression. In some cases, a dynamic field expects different code, such as an SQL statement. If you want to use an expression in this type of field, enclose it in curly brackets.
Expressions can also include variables. Some internal variables are defined in PhixFlow. The internal variables that you can use depends on the context. You can also create your own variables. As these are prefixed with the $-symbol they are called $-variables.
To find out what code a dynamic field expects, or which internal variables are available, check the help for the properties tab in which you are working. At the top of the properties tab, click
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
As well as the internal variables, PhixFlow has lots of functions that you can use in expressions.
Tables have several dynamic fields where you affect the data records in the table
The pages in this topic provide information on writing your own expressions, from simple assignments to complex looping operations.
Expression Basics | Basic operations (+, -, *, /), $-variables, variable types, assignment statements, object types and commenting scripts. |
Expression Style | A summary of the recommend scripting styles e.g. how to lay out an if clause and how best to name variables. |
Using Variables | How to use variables in PhixFlow expressions. |
Internal Variables | A list of all the pre-defined variables in PhixFlow. Depending on the context of your expression, only some of these will be appropriate to use. |
Text Expressions and Escape Characters | Information for including text strings in expressions, characters that have special meanings, and how to escape them. |
Regular Expressions | How to use regular expressions that match strings in the data. |
Conditional Statements | How to conditionally control the flow of your script using the if() and switch() functions. |
Looping Statements | How to execute blocks of script a number of times. |
Arrays and Record Sets | Handling sets of data. |
Sequence | Create a series of unique identifiers. |
Macro | Encapsulate an expression so you can reuse it in different places. |
Referencing Files and Images Via a Soft Link | How to use paths to access files on the PhixFlow server. |
Managing 4-byte Characters | How to handle invalid characters. |
Binary File Grammar | Information about how to extract data from binary files, if you need to load them using a file collector. |
Functions | The full list of all the PhixFlow functions. For example the lookup function is for filters and dynamic lookups on Pipes. |