Functions
Functions in the Multogram Modules Constructor: the Main function, your own functions with parameters and a return value, calling them with Call Function, folders and the function manager.
A function is a separate scenario called from others. Functions make a module readable: each solves one task — sign in to an account, send a message, write a report — and Main puts them together.
Main — the entry point
The module's work in each thread starts with the Main function. It can't be deleted, renamed or called from another function. Other functions run only when they are called.
The new module template has three functions, each with its own role:
| Function | Role |
|---|---|
| Main | Hands accounts out to threads and catches errors — usually you don't need to change it |
| ProcessAccount | Work with one account. The module's actions are added here, in the THEN branch |
| AuthSession | Signs in to the account with its files and proxy. Returns true or false |
This keeps the scenario readable as it grows: a new task means a new function called by ProcessAccount. See Your first module.
The function manager
Manage Functions in the second row of the top bar opens the project's list of functions:
- + — create a function, the folder button — create a folder;
- the pencil — edit, the bin — delete, the folder icon — move to another folder;
- under the name — the number of parameters, whether the function returns a value and how many actions it has;
- a click on a function opens it on the canvas.
Folders are only for order: "Sign-in", "Sending", "Reports". You switch between functions with the arrows next to the manager button or the Alt+← / Alt+→ keys.
Create a function
| Field | What to enter |
|---|---|
| Function Name | Latin letters, digits and _, starting with a letter: SendToChat |
| Description | What the function does — visible in the manager and in tooltips |
| Folder | Optional |
| Parameters | Input data: the name and type of each |
| Return Value | Turn on if the function gives back a result; the Output Variable — where it goes on the calling side |
Call a function
Add the Call Function action from the Logic module and pick the function. Each parameter
gets its own field — Value for …: put a [[variable]] or a {{resource}} there.
Inside the called function a parameter is available as a variable with the same name: the sessionFile parameter
is [[sessionFile]]. The function returns a value with the Return action, and the calling side gets
it in the result variable — [[functionResult]] by default.
Pass results through Return
Variables created inside a function stay inside the call when the module runs. In a constructor test they may be visible to the calling function — and a module that works in the test will break for the user. Return everything the calling side needs with the Return action.
When to move actions into a function
- The same actions repeat in several places.
- A block solves a separate task that is convenient to check on its own: a test runs right on the open function.
- The function needs to run in parallel — through the Tasks module, see Threads and accounts.
Updated
Variables
[[name]] variables in the Multogram Modules Constructor: where they come from, value types, object fields and array elements, local and global variables in a multi-threaded module, viewing them in the inspector.
Resources and the module form
{{name}} resources in the Multogram Modules Constructor — the fields of a module's settings form: field types, required fields, groups in the layout manager, visibility conditions, translations, test values and the account picker field.