Working with Routines

Navigation:  How to Work with Programs >

Working with Routines

Previous pageReturn to chapter overviewNext page

 

Overview

 

A Routine is a set of processes created to perform recurrent or shared functions on a local level (inside a program). It is similar to a local procedure.

A program can contain as many routines as necessary.

 

 

To Add a Routine to a Program

 

To add a routine to a program proceed as follows.

 

Step-by-step

 

1. Go to the tree view and right-click any element, within the program, where the routine must be included.

 

2. In the right-click menu, select the "Add Routine" option to open a "Routine" window.

 

3. Enter a name and, if required, any necessary notes.

 

 

4. Click to advance to another window in which processes can be added to perform additional routine functions. See Adding and Editing Processes.

 

 

5. To finish the addition of a routine, click .

 

 

To Call a Routine

 

A Routine can be called using a "GoSub" process, in which case, the routine should finish with a "Go to <Exit>". When the routine is finished, the application's execution will return to the process after it was initially called. In other words, back to the location from where it was originally called. See Working with GoSub Process.

 

EX: Calling a routine with a "GoSub" branch process means that the routine itself should end with a "Go to" process, target destination "<Exit>".

 

 

In addition to using a "GoSub", a Routine can also be called using a "Go to" Branch Process. Then, it should be finished with an explicit “Go to End of Action/Routine” branch process. Therefore, after running the routine, the application will continue to the next screen or routine available in the program tree or a "Go to" branch process with a "<Routine>" or "<Screen>" target location selected. See Working with Go To Process.

 

EX: Calling a routine with a "Go to" branch process implies that the called routine should end with the "Go to End of Action/Routine" process.

 

 

 

To Import a Routine from Library

 

Step-by-step

 

1. Use one of the following to access the "Library Manager" window:

 

A. Go to the "Menu Bar", click "Tools" and, in the resulting menu, select "Library Manager".

 

 

B. Click <F4>.

 

C. Right click a program or a routine and select "Import Routine" from the drop-down list.

 

Right click a program

Right click a routine

 

Whichever the option chosen (A, B or C), it opens the "Library Manager" window.

 

 

If required, select a different source library or rename it by clicking . See To define a Library.

 

 

If you used the A or B option, continue to step 2.

If you used option C, proceed to step 3.

 

2. Select the element type ("Routines") you want to import in the "Group" section, to the left.

 

 

A list of available routines for import is displayed.

 

3. Use one of the following to access the "Import into Project" window and continue the import operation:

 

a. Double-click the routine you want to import.

 

b. Drag and drop the intended routine into the target program (in the "Programs" module).

 

 

c. Select the intended routine and click .

 

d. Right-click the selected routine and click the "Import to Project" option.

 

 

The corresponding "Import into Project" window opens.

 

 

This window displays information that cannot be edited (regarding the routine being imported) and information you can edit (the "Destination" section).

 

4. Maintain or enter new information, as required by the project.

 

Import Routine

Displays the routine's name. NOT editable.

Displays the routine's author and when the routine was added to the library. It can also include notes entered during the export into Library operation. NOT editable.

Destination

Program

Select the target program for the import from the drop-down list.

Routine Name

Maintain or enter a new name for the routine. Make sure the target program does not have a routine with the same name.

Import Routine Resources (x)

If the routine contains resources, check this option to ensure they are included in the import. Their destination is the target project's "Resources" module.

 

 

It is possible to add project resources (appended during the routine's export into the "Library" - see To Export a Routine to Library) to the routine's import, even though they are not included in the routine.

a. To view all project resources, click .

b. Check the project resources you want to include in the import.

 

c. If you want, click to hide the resource list.

 

5. Click to conclude the routine import.

 

The newly imported routine is displayed in the "Programs" module, in its destination program, and ready to be used in the project.

 

 

If the imported routine uses a global variable that is already in use, in the destination project, it is renamed after the global variable of the current project.

Ex: The global variable A0, contained in the imported routine is named "Test2". The global variable A0 of the current project is named "Test1". After the routine import, the global variable "Test2" is renamed "Test1" according to the global variable of the current project.

 

 

Example of an Import Alert

 

 

The marks an occurrence. This example includes two issues:

The destination program already contains a routine with the same name as the one to be imported.
The destination project contains a resource with the same name as the one being imported.

 

Example of an Import Error

 

If the name of the routine to import already exists in the current project, the following message box opens:

 

 

a. Click and replace the existing routine for the newly imported one.

 

OR

 

b. Click to return to the " Import into Project" window, change the routine's name in the corresponding box and click to conclude.

 

 

To Export a Routine to Library

 

Step-by-step

 

1. Open the "Programs" module.

 

2. Right-click the routine you want to export.

 

 

3. In the resulting menu, select "Export Routine" to open the "Export to Library" window.

 

 

If required, select a different source library or rename it by clicking . See To define a Library.

 

 

4. Fill in the following options:

 

Routine Information

Routine Name

Displays the routine's name. Maintain or enter a new name.

Text Box

If required, add notes regarding the routine being exported.

Add Routine Resources(x)

If the routine contains resources, check this option to ensure they are included in the export.

 

 

It is possible to append project resources to the routine's export, even though they are not included in the routine.

a. To view all project resources, click .

b. Check the project resources you want to include in the export.

c. If you want, click to hide the resource list.

 

5. Click to conclude the export.

 

The exported routine is available in the Library ("Routines" section) and ready to be imported into another project.

 

 

Example of an Export Error

 

If the library already contains a routine with the same name, the following message box appears:

 

 

a. Click to overwrite.

 

OR

 

b. Click to return to the " Export to Library" window, change the routine's name in the corresponding box and click to conclude.