Process Actions
Process actions are steps which can be included in a Process.
Like all steps, they are executed unless they are nullified by some precondition being false.
This is the multi-page printable view of this section. Click here to print.
Process actions are steps which can be included in a Process.
Like all steps, they are executed unless they are nullified by some precondition being false.
Variables are values which can be updated.
They are created within the Values tab, and can be used and updated within Process steps.
To update a Number Variable, you
- Underweight = <18.5
- Normal weight = 18.5–24.9
- Overweight = 25–29.9
- Obesity = BMI of 30 or greater
In the video below,
we have set up two number input questions to ask the user for weight in kg and height in m.
We introduce a number variable bmi.
We add an Update variable action with the BMI formula. When this executes, the value of the bmi Variable is updated.
We add a text display where we include the bmi variable to inform the user of the value of bmi which has been computed on the basis of the input values.
Then we debug to test it out.
The value calculated is rounded to the nearest integer because we set the bmi variable to have zero decimal places when we created it.
We could edit the decimal places of the Variable for greater precision.
Another way of calculating a new value for a number Variables you might want to use is by determining a number of periods- how many months/weeks since/until from one date to another date.
Imagine you are creating an App to advice pregnant women.
As an approximation to gestation date, you may take the date of last-known menstrual period (LMP).
Then, to give good advice, your App may need first to figure out how many weeks along any particular woman is.
This is how we can compute this in Logiak:
We can use the example of pregnancy here too to illustrate one way we might want to calculate a new date value.
If we know a woman’s LMP (Last known menstrual period), we can also know the EDD (expected delivery date) by figuring out what the date is 40 weeks after the LMP date.
Here we create a variable edd to represent Expected Delivery Date, and calculate a value for that by explicitly saying we want the date which is 40 weeks after LMP (Last known menstrual period)
Logiak builds an expression for us.
The following video shows creating and updating of a set Variable.
Please checkout Reasoning with Sets for explanation
This action fetches an object instance from the database which becomes the value of this action.
The value of this action has the data type object instance.
You can use dot notation to access its constituent field values.
The fetch instance action needs to know which instance you want.
We describe this by
In fact, there are three steps to configuring the fetch, and they appear in this order:
Suppose we needed to
Fetch the invoice with the largest amount from the past 12 months
you would configure it like this:
If you know the primary key of the instance you want to fetch from the database, you configure like this:
This action allows you to query the database to find out things like:
You can also add conditions and narrow the query
The numerical result will be stored as the value of this action
This is a simple action which, when executed, stops the execution of the Process.
No subsequent Steps are executed.
To update a number variable with a new value, you can provide a new value directly, or you can define an expression from which the new value can be calculated.
The expressions you can define are the normal arithmetic expressions such as
(3 * 4)
Simple expressions, but no operations, blocks of code, control flow statements.
It supports a syntax that is common to most programming languages, including systems such as Excel.
Of course, what makes this useful is that you can calculate a new value for a variable with an expression which includes other values from the Process.
The way you do this is by building the expression as normal, but quoting other values which you want to include.
So if you have a variable called amount and you want an expression to calculae 16% tax, you could use the expression:
({amount} * 16/100)
As you are editing an update expression, you may well have forgotten exactly what name you gave to a particular value in the Process.
Instead of having to quit the editor to find out, you can make use of the Expression Wizard.
Ths formulates expressions for you, and then offers you the ability to copy and paste them in.
So you don’t need to remember:
Anything really - because this is a 100% no code system, and to remember lots of arbitrary things is not fun.
To build expressions use the familiar operators for multiplication,division, addition and subtraction:
You can also make use of some mathematical functions.
We will list them below, but please note they are also available for reference via the Expression Wizard
To calculate the value of amount to the power of 10, we could have the following expression:
pow({amount},10)
Expression to round the value of amount to the nearest integer
round({amount})
Constant | ´ Notes |
---|---|
e | Base of the natural logarithms 2.718281828459045 |
ln2 | Natural logarithm of 2 0.6931471805599453 |
ln10 | Natural logarithm of 10 2.302585092994046 |
log2e | Base-2 logarithm of e 1.4426950408889634 |
log10e | Base-10 logarithm of e 0.4342944819032518 |
pi | The PI constant 3.1415926535897932 |
sqrt1_2 | Square root of 1/2 0.7071067811865476 |
sqrt2 | Square root of 2 |
When you are calculating numbers based on other numbers, sometimes you get unfortunate situations.
One of them is when you are wanting to divide x by y, but the y has the value zero. Division by zero_ is impossible and yields infinity, which is most likely not what you intended
To avoid a crash, for cases of division by zero, we arbitarily / pragmatically assign the result to be 0.
Similarly, if there is a division by zero with a multiplication (e.g. (0/0)*100)), the result is NaN which is Not A Number.
In such a case, we also arbitarily assign the result to be 0.