Global Procedures

Navigation:  How to Work with Programs > Working with Procedures >

Global Procedures

Previous pageReturn to chapter overviewNext page

 

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) or local variables.

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).

The use of global variables is not recommended in global procedures that may be exported to prevent possible conflicts with global variables already in use in a program of the target application for the import.

Global procedures do not use local variables.

 

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 “Procedures” module, right-click an empty area or "Global Procedures" (the name of the section that displays the existing global procedures) 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.

 

The name for the global procedure MUST be unique throughout the project (ex: You cannot have a program and a global procedure with the same name).

 

 

3. Go to the "Param In" tab.

 

 

4. Define the input parameters for the global procedure:

 

"Input Param Var"

Define the program variable(s), within the global procedure, that will receive data from outside. See User Defined Variables.

 

"Input Param Default Value"

Optionally, define the value(s)/variable(s) that are assigned to the "Input Param Var", in case the calling process does not map them.

 

"Description"

Use this column to add a description for the input parameter - the description will be used to identify the global procedure's input parameter(s) in a "Call Global Procedure" process.

 

5. Go to the "Param Out" tab.

 

 

6. Define the output parameters for the global procedure:

 

"Output Param Var"

Define the program variable(s) (used in the global procedure) that will return data to the outside.

 

"Description"

Use this column to add a description for the output parameter - the description will be used to identify the global procedure's output parameter(s) in a "Call Global Procedure".

 

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. Go to the "Procedure" tab.

 

 

8. Add the required processes. Use the drag-and-drop mechanism, the window's editing bar (the button), the selected row's right-click menu ("Add/Insert..." option) OR  double-click an empty row to open a process list.

See Adding Processes to Routines, "Routine In", "Routine Out", Local or Global Procedures or Global Events.

 

Always end with a "Go To <Exit>" process:

 

The use of a "Go to: <Exit>"

returns the program to the line, immediately below, that, initially, called for the global procedure.

provides the global procedure's Out Param variable values.

 

 

9. 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.

 

 

To Call a Global Procedure

 

It is possible to call a global procedure into an "Actions" tab (of a screen and/or a control), a "Routine" tab (of a routine in or a routine out) or an "Event" tab (of a global event).

You must open the intended tab and add a "Call Global Proc" process.

Once you define the global procedure you want called in the properties window of a "Call Global Proc" process (in the "General" tab), its "Send" and "Receive" tabs are automatically filled in with the "in/out parameters" you defined for the global procedure in its own properties window.

 

Example:

The global procedure "Global_Procedure_1" defined the program variable "P_Input_1" to store an input parameter and the "P_Result" program variable to store an output parameter. The corresponding descriptions for each variable ("GP Input parameter" and "GP Output parameter") are automatically used in the "Call Global Proc" process that calls for "Global_Procedure_1" to identify the input/output parameters.

The name of the program variable only appears in a "Call Global Proc" process if you did NOT fill in the "Description" column of the called global procedure's "Param In"/"Param Out" tabs.

 

Global Procedure's In/Out Parameters

In ("Send" tab) /Out ("Receive" tab) Parameters of a "Call Global Proc" Process

 

 

As an alternative, you can use the following shortcut to include a global procedure to a screen, a control, a "routine in", a "routine out" or a global event:

If you drag a previously created global procedure from the "Global Procedures" tab onto a screen/control (specifically, to the "Actions" tab), a "routine in"/"routine out" (onto its "Routine" tab) or a global event (onto its "Event" tab), it automatically adds a "Call Global Proc" process.

 

 

For a more detailed information on how to call a local procedure, see Working with Call Global Proc Process.

 

 

To Add Components to a Global Procedure

 

In the "Procedures" module, right-click the intended global procedure (represented in the tree view) and select the component to add.

 

 

Edit

Opens the global procedure's properties window.

 

If the selected element is a locked imported global procedure (from Library), it is NOT editable. The corresponding properties window will be inactive (displayed in gray).

Copy

Copies the selected global procedure.

Paste

Pastes a copied element. Only available if there is a previous "copy" operation.

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 Export

Export the selected global procedure to Library. See To Export a Global Procedure to Library.

Library Import

Import a global procedure, screen or routine from Library.

See To Import a Global Procedure from Library, To Import a Screen from Library and To Import a Routine from Library

Search in ...

Opens the "Search" window. See Detail of Search.

 

The "Search in..." option in this right-click menu enables an automatic to search in the selected global procedure.

 

Search 'xxx'

Opens the "Search" window. See Detail of Search.

 

The "Search 'xxx'" option in this right-click menu enables an automatic search of the selected text string in the current project and returns all the occurrences.

 

 

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 "Procedures" module.

 

2. Right-click the global procedure you want to export.

 

 

3. In the resulting menu, click the "Library Export" option 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").

 

 

Click Here for Examples of Export Errors

 

 

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 "Procedures" module  and select "Library Import".

 

 

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 a Voice Add-on.

 

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 "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 is being developed with an MCL-Designer V4 that does NOT include the required MCL-Voice add-on, 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 "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.

 

 

Click Here for Example 1 of an Import Alert

 

Click Here for Example 2 of an Import Error