This is the multi-page printable view of this section. Click here to print.
Values
- 1: Values
- 2: Values Convention
- 3: Variable Values
- 4: Functions
- 5: User inputs
- 6: Object Instances as Inputs to a Process
1 - Values
Values
What are values?
Values can be simple or complex
Simple values
Simple values are numbers, truth-values (true & false), bits of text. Examples:
4389
true
Billy Bunter
Complex values: Object instance
Logiak also allows values to be Object instances which is a record made up of several fields, each of which have (simple) values.
Value names
In a Logiak Process values have names.
These are usually short and “symbolic” (i.e. lowercase, no spaces or hyphens ..), but should seek to be mnemonic (remind you what value they represent).
For example, the “simple” values above might have names such as:
invoice_id
invoice_is_paid
customer_name
Referring to simple values
Names let us refer to values, even when we don’t actually know what the values are.
Everyone is likely familiar with maths at school where values get associated with names: “let x equals 5…”
For simple values, surrounding the value name with braces gets us the value
{x}
This expression might represent the value 5
{customer_name}
This expression might represent the value Fred Bloggs.
Read more about how to refer to values, including how to refer to field values within object instances´values
Four sources of values in Logiak
2 - Values Convention
Simple values
Surround value names with braces (squirly brackets) to access the current value.
Example: if you have a value called age-in-years (could be a variable, or a user-input value), this expression represents the value represented by the name:
{age-in-years}
Showing values in Process Interaction
Named values can be presented to the user in Process steps by surrounding the value name is braces.
Example: if you have defined a variable named age-in-years, you can inform the user about this value in an interaction, by including something like the following in the interaction text:
Client is {age-in-years} years old
Using values in calculations
One of the actions available is Update variable action.
To use this action you need to specify an expression to calculate a new value for the variable you are updating.
Example variable update
For example, suppose you have a value called amount and you want to update a variable tax so that its value is 16% of the invoice value, you can give the following expression to an Update Variable action to update tax
{amount} * 16/100
Object instance data type
Values can be “simple” - which means a number, some text, a date, etc.
They can also be “complex” because a whole Object instance can also be a value.
An Object instance, because it has several fields, has several values.
Dot notation : instance-name.fieldname
How do you refer to a specific value within the instance?
EXAMPLE:
Suppose you have the following:
- you have defined an object type called invoice containing three fields (invoice_date,amount, customer)
- you have a Process which has an instance of invoice with the value name inv1
You can refer to the value of the customer field of inv1 like this:
{inv1.customer}
3 - Variable Values
A Process can make use of variable values (we can also just refer to them as variables).
Variables
Variables are named values which have an initial value, and can be updated at any point within a Process via Update Variable actions.
To define a variable is to :
- choose the type (numerical, date, etc)
- give a name (must be symbolic)
- give an initial value
- optionally give a description / comment to help remember the meaning of the variable
Using variable values
Presenting values to the user
The value of a variable can be presented to the user in Process steps by surrounding the variable name is braces.
Example: if you have defined a variable age-in-years, you can inform the user in some step:
Client is {age-in-years} years old
Using values in calculations
One of the actions available is Update Variable.
You can define an Update Variable action and specify an expression to calculate a new value for a given variable.
For example, suppose you have defined a variable invoice-value and you want to update another variable tax so that its value is 16% of the invoice value, you can give the following expression to an Update Variable action action to update tax
{age-in-years} * 16/100
How to DELETE a variable
A Variable can be deleted only when there are no references to it.
When that is true, the variable will appear in lighter colors, and moving the mouse over it will expose a trash icon
How to view the USES of a variable
When a Variable is not deletable, it is because it is in use somewhere within your project, and to delete it would be to create the conditions for a software crash.
If you want to know where it is being used, Logiak can tell you:
4 - Functions
Calculated Values (functions)
Some values are input by the user.
Some values are variable values which can be updated.
One can also define functions, which are values dependent on other values
You can also think of functions as variables which are updated at every step of the Process.
Example: defining a tax function
In Convention, we show an example defining a variable called tax, and using an update variable action to give it a new value after the user enters an amount.
Here we can see a different way of achieving the same thing: defining a function called tax which is dependent on amount
5 - User inputs
User inputs
If you have a number input question in the Process, that has an associated value name which is initially generated for you (the generated names are like v1, v2, etc), but which you can edit to be something more meaningful at any time.
6 - Object Instances as Inputs to a Process
Input instances
Object instances are structures usually containing several fields with values. Think: row in a spreadsheet, or row in a database table.
In the Values tab, you can configure a Process so that it has an Object instance as input.
That is, you can say that this Process has access to an instance of a given type.
Instances can also become values by being fetched
As well as being used within a Process by being inputs parameters, the values within object instances can also be accessed by fetching instances from the database within Process actions.Example
Let us illustrate with a simple example.
Declare input instance in Process
Suppose you have defined a patient object with just three fields (uid,name,age):
Now let’s look at creating a Process, and the first thing we will do in the Process is go to the Values tab and say that this Process has a patient as input
Access value of instance
What can you do in the Process with the input?
You can access the values in the patient record which has been passed in in both actions and interactions of the Process by using the Logiak convention for variables: