Update Variable Action
Variables
Variables are values which can be updated.
They are created within the Values tab, and can be used and updated within Process steps.
1. Updating a Number Variable
To update a Number Variable, you
- choose the Variable you want to update
- then you provide an expression which will give the new value
Body mass index (BMI) example
- Underweight = <18.5
- Normal weight = 18.5–24.9
- Overweight = 25–29.9
- Obesity = BMI of 30 or greater
Body Mass Index formula
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.
Note on precision
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.
Calculating a number of periods (months, weeks, etc.) since/until …
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:
2. Updating a Date Variable
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.
3. Updating a Symbol Set Variable
The following video shows creating and updating of a set Variable.
Please checkout Reasoning with Sets for explanation
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.