Lifespan of types in Linx

While using Linx you will most definitely want to assign data to different objects / types. While doing this, it is important to know that each object has a specific lifespan, from when you can access or change it, up to a point when you can no longer access it.

Before we demonstrate these lifespans, we need to note that there are different kinds of objects / types in Linx which can be used. They are:

  • Normal types: Like strings, integers or custom types which are drag-and-dropped into your process.
  • Function Results: Results generated by a function, i.e. FileRead can generate a string of the contents of a file.
  • Process Inputs: Assigned a value when the process starts.
  • Process Outputs: Clear at process start.

Each of these can be accessed during their lifespan.

The Lifespans:

To demonstrate the lifespans, consider the following figure:

I’ll be using the Strings (from String1 to String9) as the different positions where we can test the lifespans. Two important considerations when working with types are, when they are defined (how high up they are on the list) and how deep they are defined within a branch.

  • You cannot access a type that is only defined below the position you are busy with.
  • You cannot access a type that is defined in a branch you are not part of, or that is defined deeper in the branch than where you are.

Inputs:
Before we even start with the strings, we can consider the Inputs of the process. Any Input type can be accessed throughout the whole process, from 1 up to 9. Only once the process ends, the Input type will reach its lifespan end.

String1:
This type is defined right at the top of the process, and will be available throughout the rest of the process in all the positions. 1 to 9. However, once the process ends, String1 will end as well.

String2:
String2 was defined within the “Try” branch of a TryCatch. Thus it will not be accessible before the “Try” branch starts. String2 will be available in positions 2, 3, 4. Important though, if an exception occurs, String2 will not be available at position 5, in the “Catch” branch. Once the “Try” finish, String2 will end as well.

String3:
String3 is defined in “Branch1” of the IfElse. It will only be available within this branch (at position 3). Thus, it will not be available in position 4 (or anywhere else).

String4:
String4 is defined in “Branch2” of the IfElse. It will only be available within this branch (at position 4). Thus, it will not be available in position 3 (or anywhere else).

String5:
This string was defined at the end of the “Try”. It will not be available before, thus even though its in the same level and branch as String2, at position 2 you will not be able to access String5. Once the “Try” ends, so will String5. It will only be accessible at position 5.

String6:
String6 is defined on the root level, after the TryCatch, and before everything else. It is not available at position 1,2,3,4 or 5, but will be available at position 6,7,8 and 9.

String7:
When doing SQL queries, or any data queries which will return multiple rows, the branch “ForEachRow” will repeat in its entirety. For each repeat String7 will be redefined. String7 will not be available between different repeats, it will be a brand new string. Thus, String7 will only be available in position 7, and only in the current repeat. The data in String7 will be cleared when the current repeat completes.

String8:
When doing loops of lists, the branch “Loop” will repeat in its entirety for each item in the list. String8 will be redefined each time. String8 will not be available between different loops, it will be a brand new string. Thus, String8 will only be available in position 8, and only in the current loop. The data in String8 will be cleared when the current loop completes.

String9:
String9 is defined at the last position in the process, and will not have been available for access at any point above in the process. Also, as soon as the process completes, String9 will end as well. An interesting note is that at this position, being at the end of the process, you should be able to access String1, String6 and String9. The rest of them are within levels of branches, and not accessible.

Outputs:
An output will be available throughout the process, and this variable is also the only variable that can be accessed once a process completes.