VALUE_OF

The function VALUE_OF takes a variable of any data type and returns its value.

This function takes as single variable of any data type as input. It returns the value of the given variable. 

Declaration

VALUE_OF(input) -> input_value

 

Parameters

input (required, type: any)
A variable of any data type.

Return Values

input_value (type: any)
The value of the variable given as input.

Examples

The VALUE_OF function must be given a variable as input. Hardcoding input will cause it to throw an error, as in the following example:

VALUE_OF(3) -> ERROR

Assume all subsequent examples have access to the following variable, example_number:

example_number = 3

Giving example_number as input to the function VALUE_OF causes it to output the number 3:

VALUE_OF(example_number) -> 3

The function VALUE_OF accepts all data types as input, including Lists and App Objects, which themselves might contain different types of data. For instance, assume all subsequent examples have access to the following variable, example_object. Note that example_object had two properties: "number", and "name", the values of which are a Number and a text data type, respectively:

example_object = {  
 "number": 3,  
 "name": "Alice"  
}

The relatively complexity of example_object does not prevent VALUE_OF from returning the value it contains when given example_objectas input:

VALUE_OF(example_object) -> {  
 "number": 3,  
 "name": "Alice"  
}

Discussion

In the vast majority of cases when the value of a variable is needed, it can be accessed simply by calling on the variable itself. That is, given some variable example:

VALUE_OF(example) = example

In these cases, use of the function VALUE_OF is unnecessary. This is because, by default, variables in Airkit are writable.

However, under very particular circumstances, such as when working with Custom Controls, a variable might be readOnly when a  writable variable is needed. Giving a readOnly variable as input to VALUE_OF returns a value that can be saved as a writable variable.