Update Variable Action
Variables are values which can be updated.
1. Updating a Number Variable
To update a Number Variable, you
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.
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
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.