Variables processing

Table of contents


Description

A variable is a container in memory that can take a given or computed value. Variables in ZennoPoster can be created, changed name of a variable and deleted, as well as assigned different values. The most convenient way to work with variables is through the " Variables " window.

You should separate C# variables that are strongly typed and project variables that are not strongly typed. However, the values of these two types of variables can always be converted without data loss or distortion.

Variables are the backbone of any programming project.


How to add an action to a project?

Via the context menu Add Action -> Data -> Variables processing

Or use smart search.

What are they used for?

  • To set and change the values of variables.

  • To increase or decrease the value of the counters.


How to work with an action?

Set value

You can assign static strings, numbers, values of other variables, values of environment variables, and also combinations of the above data to a variable.

Increase\Decrease counter

Counter mode is possible for both increasing and decreasing the value. In this case, the counter can be increased or decreased not only by one but by any number specified in the “Value” field. The value of the variable that is selected in the “Variable name” field is increased / decreased.

Clear variables

Added in ZennoPoster 7.7.0.0

Using this action you can clear variable values.

There are three modes:

  • All

  • The listed

  • All except listed

It might be useful when there is a loop in a project and you have to clear variable values before the new iteration. So the values from the previous iteration won’t affect the new one.

Global Variables and Namespace

Ordinary variables are visible only within one project thread (if the project works in multi-threaded mode, then each thread will have its own local, independent variable)

Global variables are available for all projects and their threads in ZennoPoster.

In order to avoid confusion, global variables have an additional property - the Namespace, which must be specified during creation and when accessing.


Examples of using

Let's look at some practical examples of using variables in projects.

Assigning a value to a variable

The variable value can be assigned or changed as in a special window Project variables , and with the help of the cube " Data " → " VariablesVariables processingprocessing"

In this example, an email address is generated based on the string variables of the login and domain of the site.


Working with counter swapping and environment variables

Consider a synthetic task in which we need to list ten current time stamps.

  1. Let's create a variable count , which will be a counter and assign it the value 0 using the cube “ Variables processing ”.

  2. Using the same cube, get the current time stamp using the {-TimeNow.TimeNow-} environment variable, add it to the time variable and store the resulting value in the same time variable.

  3. Now we need to repeat the procedure from step 2 9 more times. To do this, compare with the “ IF ” cube Condition "If ... then ..." (Statement "IF") count value with a maximum value of 9 .

  4. If the condition is not true (the counter is less than or equal to 9), then we increase the count by 1 using the “ Variable processing ” cube (the “ Increase counter ” property) and repeat step 2.

  5. If the condition is true (the counter is more than 9), then we end the processing and output the resulting value of the time variable to the log. We can see the result of the project in the " Variables " window.

Useful links