Basic Functions (WiP)

Basic functions are essential for data processing and serve as the foundational components for developing business logic. To utilize the basic functions:

  1. Find the Functionality panel on the left-hand side of the screen

  2. Expand Utilities and then Basic Functions

  3. Drag the function you want to use into a section on the logic board

Returning the same value

The echo function returns the given input without modification. It can be utilized for intermediate processing within a workflow or for debugging purposes. Additionally, echo serves as a method to generate static input values within the application logic.

Combine data into array

With combine, you can add two or more arguments into an array structure. You can mix different types of data and manually write data into the input boxes. To combine more than two arguments, you need to add more input boxes.

To combine data into an array:

  1. Drag an output onto the first input box or write a static value into it.

  2. Repeat for the second input box.

  3. Optionally add more input boxes by clicking the + symbol next to the existing input boxes and repeat the first step for them.

  4. Trigger the function and check if the output matches your desired format.

Adding a string and an object into an array

Merging objects

mergeObjects can combine two or more objects into one.

To merge objects:

  1. To add more objects, click the + symbol next to the initial input box. This action will create a new input box for each additional object you want to add.

  2. Drag the object boxes onto the inputs in the order you want to add them together.

  3. Trigger the function and expand the output to see if it matches your desired format.

Merging of two Objects

Appending to an array

The arrayPush function appends arrays or individual items to an existing array. To add items or arrays, include them as arguments. Manual static inputs are also supported.

To create a new array:

  1. Drag the array you want to extend onto the first input.

  2. Then drag the items individually into the further inputs, following the order you in which you want to add them.

  3. If necessary, simply add new input boxes by clicking the + icon after any existing input box.

  4. Trigger the function.

Attaching an item to an array

Mapping a range

The mapRange function transforms a numeric value from an original range to a target range, both of which are defined by the user. This utility allows for scaling of numbers to fit into different numerical contexts or representations.

To map a range:

  1. To enter a value for mapping, type it directly into the first input field or drag and drop an output value onto it.

  2. Define the ranges in the second input by writing the names of the corresponding variables with a colon, then a space and then the value.

  3. Hit enter for a line break and add the next value.

You may copy the code below and insert it into the input box, then define the ranges by replacing null with your values.

origMin: null
origMax: null
newMin: null
newMax: null
Mapping value 5.5 from range 0 to 10 to range 0 to 100

Adding a delay

The delay function allows you to postpone the propagation of a value in your application, providing greater control over when specific actions occur.

To configure a delay:

  1. The first input field specifies the ID for the delay timer. This ID is required and needs to be unique for each delay.

  2. Add a second input field to insert or link your value.

  3. Introduce a third input field and specify your desired delay in milliseconds (e.g., timeout: 5000 for a five second delay). If this field is omitted, a default of 1000 milliseconds (one second) is applied.

  4. Drag your value onto the Trigger to ensure this delay is activated whenever the input value is modified.

    • If you wish to trigger this delay with every input update, even when the value remains the same, click change in the Trigger section and select the appropriate operational mode.

A delay with a timer of 5 seconds

Checking for true parameters

Checking for all true parameters

To execute a logical AND operation across multiple variables, you can utilize the areAllParamsTrue function. It returns true when and only if every provided input evaluates to true.

The truth value of the result is determined as follows:

  • Leaving a box blank, inserting NULL, 0 or false or having fewer boxes than the defined number of parameters will result in the output false.

  • Any other value in the input boxes will result in true

  • Additional boxes above the defined number of parameters will be ignored ONLY if they are empty. Otherwise, the output will be false.

How to apply the AND operation:

  1. Define the number of needed parameters in the first input box.

  2. Add the amount of necessary input boxes.

  3. Manually insert or link data.

  4. Trigger the function or create a conditional trigger by linking.

Logical AND over three different values

Checking for one or more true parameters

The isOneOrMoreParamTrue function operates using a logical OR operation, in contrast to using a logical AND operation. This function returns true if at least one of its given parameters is true.

Filling an input box with content other than leaving it empty, entering NULL, 0, or false is interpreted as true.

In contrast to areAllParamsTrue, you don't need to define the number of input boxes. Just follow these steps:

  1. Create however many input boxes you need.

  2. Manually insert or link values.

  3. Trigger the function or create a conditional trigger by linking.

Logical OR with two inputs

Converting JSON data to a string

jsonStringify automatically converts an input to a suitable JSON string. The input should be an object or an array. Subsequent input boxes after the first one are ignored.

Hello World example for object to JSON

Parsing JSON data

The jsonParse function can interpret JSON data from outputs, transforming them into objects that can be utilized in other functions.

NOTE: When manually specifying JSON in a function's input, it is automatically converted into an object. Therefore, explicitly converting it with this function is unnecessary.

Extended Hello World example for JSON to object

Merging arrays

mergeArrays is a function designed to combine multiple arrays by nesting their elements one level deeper into a new array structure. It requires at least one array as input.

The function compares the lengths of the input arrays and creates a new array with the length matching the shortest input array. Elements from the original arrays are repositioned as sub-elements at their respective indices within this new array. Any elements beyond the length of the shortest input array are omitted in the output.

To merge arrays:

  1. Add input boxes as needed.

  2. Drag arrays from outputs onto the inputs or specify them manually.

  3. Trigger the function or create a conditional trigger to run this every time an input array changes.

Merging of two array with differing lengths

Combine arrays

Group arrays

Renaming object keys

The renameObjectKeys function is designed to modify the keys in an object based on a provided mapping. It requires two parameters:

  1. Source Object: The object whose keys need updating, containing original key-value pairs.

  2. Mapping Object: An object defining the new key names, with each property pairing a new key name with its corresponding old key name newKey: oldKey.

Remember to write each mapping in a new line by hitting enter.

For source objects with variable key names, you can drag a dynamic key mapping object into the second input to adapt accordingly.

Renaming keys in an object

Memory

Trigger

Last updated