Module_LibraryVariables

Type: Module Parent Module: N/A

This module will fix the problem associated with use of library variables and multiple libraries. Omnis 7 library variables are converted by the built-in core converter in Studio to task variables that have a different scope. To correct this in a situation where an application comprises more than one library using this converter module the developer must nominate a master library. Other libraries are then regarded by this module as children of the master library. All task variable definitions are copied from the child libraries to the master library. Since there is only a single Startup_Task instance all these variables effectively become global variables that are available to all instances.

Warning. This behaviour is different from that of the original library variables in Omnis 7. It is however the nearest type of behaviour exhibited by a variable in Omnis Studio, other than using memory only file classes and should give satisfactory results, except where the multiple libraries are expecting to be able to maintain different values in library variables that have the same names as those in the other libraries. If this does not suit your requirements then you need to go back to Omnis 7 and rename the library variables so that they have different names in each library before converting to Studio.

The converted system must be run in such a way that the master library is opened first and is resposible for instantiating classes in all libraries. This will ensure that the correct task variables are always in scope.

Functionality

Before running the Converter the developer must first select the master library that will eventually contain all the task variable definitions. See User Setup Required for this Module below for instructions on how to do this.

Check if the master library is open. If not attempt to open it. If unable to open it then display an error.

Check if the libary being propessed is not the master library then copy all task variable definitions to the master library as follows:

  1. The new variable will have the same name and data type as in the source library.
  2. If a variable already exists in the master library by that name then it it ignored.
  3. Otherwise copy it and remove the task variable definition from the source library.

Note that when a task variable has been removed from the source library then all references to a task variable MyVar will automatically be replaced by Studio with $ctask.MyVar and consequently the reference will be correctly evaluated at run-time to a reference to the variable in the owning task instance that exists in the master libary. This is the reason why it is important that the master library is the controlling library for the system and that its task instance owns all instances of other classes from all libraries.

Assumptions

  1. Multiple libraries are in use that contain library variable definitions.
  2. If library variables with the same name are defined in multiple libraries then the data type is consistent or the same and each library does not need to maintain a different value in the variable to the value maintained in other libraries. If this is not the case you need to go back to Omnis 7 and rename the library variables so that they have different names in each library before converting to Studio.

User Setup Required for this Module

Before running the Converter the developer must first select the master library that will eventually contain all the task variable definitions. To do this:

  1. Select the Convert... option from the O$Converter main menu.
  2. Select required library from the list on the Select Library to be Converted window.
  3. Select Module_LibraryVariables from the Modules menu on the Select Library to be Converted window.
  4. If the required master library is not open then click the Open... button to open it.
  5. To set the master library for the current library select the master library in the list and press the Select button (nb. set the master library for the master libary to be itself).