Global Procedures
Overview
A Global Procedure is usually created to perform a recurring action. Basically, it is considered a standard program that can be reused in other projects.
This procedure does not use global variables to prevent conflicts with global variables being used in a program.
To exchange data between the program that called this procedure and the global procedure, it is mandatory to define "input" and "output" parameters.
It is possible to reuse global procedures via an export/import. The global procedure is exported into Library (a shared folder that stores exportable elements such as data files, programs, global procedures, screens, etc.) - see To Export a Global Procedure to Library. Afterward, it becomes available for future import into another MCL-Designer V4 project that requires its use (see To Import a Global Procedure from Library).
This illustration displays the structure of a Global Procedure as is displayed in the tree view. It contains screens, routines, controls and a local procedure. |
To Add a Global Procedure to a Project
Step-by-step
1. To add a global procedure to a project, open the “Global Procedures” module, right-click an empty area and select the “Add Global Procedure” option.
2. This opens a properties window.
In the "General" tab, enter a name for the global procedure. This name is displayed in the tree view.
Optionally, notes can be added to the global procedure.
3. Go to the "Param In" tab.
4. Define the input parameters for the global procedure, with the use of variables. See Working with the Variables Processes Group.
"Input Param Var"
In this column, define the program variable(s) (used in the global procedure) that will receive data from the outside.
"Input Param Default Value"
In the second column, as an option, define the value(s)/variable(s) that will be assigned to the "Input Param Var", in case the calling process does not map them.
"Description"
As an option, use the third column to add any relevant notes.
5. Go to the "Param Out" tab.
6. Define the output parameters for the global procedure, with the use of variables. See Working with the Variables Processes Group.
"Output Param Var"
In this column, define the program variable(s) (used in the global procedure) that will return data to the outside.
"Description"
As an option, use the second column to add any relevant notes.
Use the editing icons to the right of the table to move the rows up and down and to delete or add more rows.
7. Click to apply these choices.
As an alternative, you can import an existing global procedure from library. See To Import a Global Procedure from Library.
Step-by-step
This operation can be executed in the "Routine", "Actions", "Event" or "Procedure" tab of the element that calls the global procedure.
Step-by-step
1. Add a “Branch Process – Call Global Proc”. See Working with Call Global Proc Process.
2. This opens the following window:
3. In the "Procedure" drop-down, select the global procedure to be called.
4. The "Param In" automatically displays the parameters established in the properties window ("Param In" tab) of the called global procedure.
Define the value(s)/variable(s) to be sent to the global procedure (mapping of the global procedure's input parameters) in the second column of the upper table.
5. The "Param Out" also displays the parameters established in the properties window ("Param Out" tab) of the called global procedure.
Define the value(s) that return(s) data from the global procedure (mapping of the global procedure's output parameters), in the second column of the lower table.
Clicking
(located on the window's upper right corner), enables the creation of a global procedure.
6. Click to apply these choices and return to the tab that initiated this operation.
7. Add a "Go to <Exit>" Branch Process to the tab. This will return the execution flow to the line, immediately below, that, initially, called for the global procedure.
8. Click to conclude.
To Add Components to a Global Procedure
In the "Global Procedures" module, right-click the global procedure (represented in the tree view) and select the component to add.
|
Edit |
Opens the global procedure's properties window.
|
|||||
Copy |
Copies the selected global procedure. |
||||||
Paste |
Pastes the previously copied global procedure. This option is only visible after a "copy" operation takes place. |
||||||
Duplicate Global Procedure |
Duplicates the selected global procedure with all its features, controls and processes. If the selected global procedure is a "locked" global procedure (not editable), this option is NOT applicable. |
||||||
Delete |
Deletes the selected global procedure. |
||||||
Add Local Procedure |
Adds a local procedure to the selected global procedure. See Local Procedures. If the selected global procedure is a "locked" global procedure (not editable), this option is NOT applicable. |
||||||
Add Screen |
Adds a new screen to the selected global procedure. See Creating and Editing a Screen. If the selected global procedure is a "locked" global procedure (not editable), this option is NOT applicable. |
||||||
Add Routine |
Adds a routine to the selected global procedure. See Working with Routines. If the selected global procedure is a "locked" global procedure (not editable), this option is NOT applicable. |
||||||
Convert to Program |
Converts the selected global procedure into a program which is displayed last in the tree view. |
||||||
Param In |
Provides direct access to the "Param In" tab. |
||||||
Param Out |
Provides direct access to the "Param Out" tab. |
||||||
Open All Screens |
Opens the screens included in the selected global procedure. If the selected global procedure is a "locked" global procedure (not editable), this option is NOT applicable. |
||||||
Library |
Provides export/import options for elements that relate to global procedures. a. Right-click the intended global procedure. b. Mouse over the "Library" option to access the following options:
c. Click the intended option to:
|
Some of the right-click menu options are not applicable if the global procedure in question is a previously imported global procedure that is "locked" (an Export option - see To Export a Global Procedure to Library below). A "locked" global procedure is not editable so, certain operations (related to a global procedure's duplication, the adding or importing of screens/local procedures/routines or opening all the included screens) are NOT executable.
If you right-click a "locked" global procedure (identified with a ) and select options that relate to its edition, you get one of the following messages:
To Export a Global Procedure to Library
Step-by-step
1. Open the "Global Procedures" module.
2. Right-click the global procedure you want to export.
3. In the resulting menu, mouse over the "Library" option and select "Export Global Procedure" 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:
Global Proc Information |
|
Global Proc Name |
Maintain or enter a new name. |
Text Box |
If required, add notes regarding the global procedure being exported. |
Export Options |
|
MCL-Designer Source Code |
Check this option if you want the settings/content of the global procedure being exported to be available for editing once it is imported into another MCL-Designer V4 project. |
MCL-Script (executable) |
Check this option if you want to lock the settings/content of the global procedure being exported (ex: name, input parameters, output parameters). This means that when the global procedure is imported into another project, it will not be editable. This affects its display in the destination project - only the name will be visible, the original components (routines, screens, local procedures) will not be available in the tree view and the corresponding properties window will not be editable. |
Add Global Proc Resources(x) |
If the global procedure contains resources, check this option to ensure they are included in the export. These resources can refer to image files, sound files, text files, language files containing the exportable element's localization tags, etc. |
It is possible to append current project resources to the global procedure's export, even though they are not a part of the global procedure.
a. To view all project resources, click .
b. Check the project resources you want to include in the export. (If you have checked the "Add Global Proc Resources" option, the corresponding resources will be selected when you expand the project's resource list.)
c. If you want, click to hide the resource list.
5. Click to conclude the export.
The exported global procedure is available in the Library ("Global Proc" section) and ready to be imported into another project.
As an alternative, you can use a drag-and-drop to initiate an export:
a. Open Library Manager (shortcut key - F4).
b. Drag the global procedure you want to export and drop it on the Library Manager's window. This opens the corresponding "Export to Library" window.
c. Proceed as described in steps 4 and 5 ("To Export a Global Procedure to Library").
Example of Export Errors
•If the library already contains a global procedure 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 global procedure's name in the corresponding box and click
to conclude.
•If you intend to export a previously imported global procedure that is locked, the following message box appears:
a. Click to cancel the action and close the window. It is NOT possible to export a locked element that was included into the project through a previous import.
•If, instead of selecting an existing "library", you enter the name of a non-existing folder to be the destination for your global procedure export, you get the following message:
a. Click .
To Import a Global Procedure from Library
Step-by-step
1. Open the destination project and use one of the following to access its "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 the empty space of the "Global Procedures" module, mouse over the "Library" option and select "Import Global Procedure".
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 ("Global Proc") you want to import in the "Group" section, to the left.
Library elements that have speech attributes, meaning, that were created within speech projects, are identified with a
(ex: Global_Procedure_2).
A "speech" element (a program, a screen, a routine, a global procedure or a global event) can only be imported into projects being developed within an MCL-Designer V4 with enabled speech attributes.
A list of available global procedures 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 global procedure you want to import.
b. Drag the intended global procedure and drop it into the destination project's "Global Procedures" module.
c. Select the intended global procedure and click .
d. Right-click the selected global procedure and click the "Import to Project" option.
The corresponding "Import into Project" window opens.
This window displays information that cannot be edited (regarding the global procedure being imported) and information you can edit (the "Destination" section).
If the global procedure being imported is a "speech" global procedure (marked with a ) and the target project does NOT have enabled speech features (MCL-Designer V4 does NOT include speech attributes), the "import" operation is aborted.
If the destination project contains a global procedure with the same name as the global procedure being imported, the name of the imported global procedure will automatically change to "..._X" ("X "refers to an incremental number.
If the global procedure being imported is "locked" (Export option that turned the selected element into a non-editable element - see To Export a Global Procedure to Library), you will not be able to edit its name. The option "Global Proc Name" will be inactive (displayed in gray).
You can either opt to change the name of the global procedure that already exists in the destination project (if it is not locked) and keep both global procedures OR proceed with the import, in which case, the newly imported global procedure will overwrite the one that already exists in the destination project.
4. Maintain or enter new information, as required by the project.
Import Global Proc |
Displays the global procedure's original name. NOT editable. |
Displays the global procedure's author and when the global procedure was added to the library. It can also include notes entered during the "export into Library" operation. NOT editable. |
|
Destination |
|
Global Proc Name |
Option only available if the element being imported was NOT previously "locked" during export. Maintain the suggestion or enter a new name for the imported global procedure. Make sure the target project does not have a global procedure with the same name or the imported global procedure will overwrite the one that already exists in the destination project. |
Import Global Proc Resources (x) |
If the global procedure 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 attach project resources (appended during the global procedure's export into "Library" - see To Export a Global Procedure to Library) to the global procedure's import, even though they are not included in the global procedure.
a. To view all project resources, click .
b. Check the project resources you want to include in the import. (If you have checked the "Import Global Proc Resources" option, the corresponding resources will be selected when you expand the project's resource list.)
c. If you want, click to hide the resource list.
5. Click to conclude the global procedure import.
The newly imported global procedure is displayed in the "Global Procedures" module and ready to be used in the project.
When the import includes language files (containing the imported element's localization tags), check the enabled languages of the destination project. If the imported language files relate to a language that is NOT enabled in the destination project, you have to define it as a project language in the project's Localization (a project properties tab). See Localization.
Ex: The import of a global procedure that includes a language file in "Dutch" into a project that only has "French" as an enabled language, will require that you add "Dutch" to the list of project enabled languages (in the Localization tab). If you skip this step, the imported "Dutch" language file will NOT be available for use.
Example of an Import Alert
The marks an occurrence. This example includes two issues:
•The current project contains a global procedure with the same name as the one to be imported.
•The destination project contains resources with the same name as the ones being imported.
Example of an Import Error
If the name of the global procedure to import already exists in the current project, the following message box opens:
a. Click and replace the existing global procedure for the newly imported one.
OR
b. Click to return to the " Import into Project" window, change the global procedure's name in the corresponding box and click
to conclude.
Option only available if the global procedure being imported is NOT "locked" (Export option).