Update Variable Action

Update variable action


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,

  1. we have set up two number input questions to ask the user for weight in kg and height in m.

  2. We introduce a number variable bmi.

  3. We add an Update variable action with the BMI formula. When this executes, the value of the bmi Variable is updated.

  4. 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.

  5. Then we debug to test it out.

Using an expression to calculate Body Mass Index (bmi)

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:

Using an expression to calculate weeks since a certain date

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.

Using an expression to calculate EDD

3. Updating a Symbol Set Variable

The following video shows creating and updating of a set Variable.

Please checkout Reasoning with Sets for explanation

Calculating a new set and updating set variable