Description
This activity makes it possible to run another workflow file (.neek format) from the current workflow.
This activity is convenient for reusing the existing workflows. This eliminates the necessity to recreate them manually. It also lets you achieve modularity while developing bots: every single subprogram can be edited separately as well as added or removed from the workflow at any time.
This is how a complete example would look like. There are some actions at the beginning of the workflow. As soon as they are complete, a subprogram is launched. Based on the result of its work, the workflow execution will continue according to the set scenario: it can either have one branch or an additional branch that is chosen in case the subprogram was not executed properly.
In this example, a subprogram is run when the preceding actions are complete. Then the algorithm continues executing other actions in this workflow
Parameters
The only parameter here is Path to file. It lets you specify the path to the workflow file that needs to be executed. It is required.
There are two kinds of paths:
- Absolute path. It is used when the required workflow file is placed in the home directory or in any other place different from the directory that contains the current workflow (higher in the hierarchy).
- Relative path. It is used when the required file is in the same directory as the workflow file (or in a child directory).
Path to file parameter
The ‘Open in a view tab’ button lets you view the workflow file you are going to set as a subprogram in a separate Studio Pro tab.
Interaction between subprograms and variables
All variables in ElectroNeek are global. This means that the scope of such variables is the entire program (including different workflows opened in different tabs). Thus, if you set 5
as a value of the variable x
in one bot, you can set the variable y=x
in the second bot, and get 5
as the value of y
.
The use of global variables allows you not to pass or return values explicitly. Nevertheless, this possibility exists. You can use the arrows connecting the blocks in the canvas to pass variables into and out of a subprogram.
Main program. Passing the value “sample text” of the variable “x” to the subprogram.
In order for an activity within a subprogram to use a variable value, you need to set the "Save the previous step result" parameter for that activity.
Subprogram. Thus, the string "sample text" will be entered in Notepad.
To return the value of a variable from a subprogram is also quite simple. To do this, make sure that the last action in the subprogram returns a value and create a "Save value to variable" block with the "Save the previous step result" parameter in the main program.
Subprogram. This activity returns the read text to the variable.
Main program. This activity saves the result from the subprogram to a new variable.