Submodule_Methods_HideDisab

Type: Submodule Parent Module: ModuleCMethods

Module Submodule_Methods_HideDisab
Version / Date Version 2.2 - 23rd January 2002.
Author (Organisation) Kevin Gale (Newcastle Computer Services Plc)
e-mail keving@ncs-plc.co.uk

This submodule converts certain commands that use tab order to manipulate fields on windows with equivalent notation commands. If possible the field will be referenced using its $name property. If a number of fields are manipulated using a range (say field number 6 to 9) then if the range does not exceed a preset threshold, then the command will be converted to reference each field within the range. Otherwise the notation method "$sendall" is used to manipulate fields within a From and To range of $order. Note that this approach has the disadvantage that changing the tab order of the fields on the window will have an effect on the fields modified by the notation command whereas the first 2 approaches remove this dependency.

Functionality

Search for the following commands in methods:

  1. Show fields.
  2. Hide fields.
  3. Enable fields.
  4. Disable fields.

Process any line of code found that contains one of these commands. The aim is to replace existing commands that use the $order property to reference a field with the name of the field.

Process the code line as follows:

  1. Determine the "From" and "To" field numbers.
  2. If the "From" field is empty, give it a default value of 1.
  3. If the "To" field is empty, give it a default value of the "From" field.
  4. Check the "From" and "To" parameters to detemine if they are simple or a complex. A complex parameter will include at least one of the characters +-*,(
  5. Strip "OBSOLETE COMMAND" from the original line if it is found there.

Simple Parameters

For a command that is simple and where the numerical difference between the "To" and "From" fields is less than a threshold held in an instance variable called "iExpandOrderLimit", look up the name of all referenced fields using the $order property of each.

If the command refers to a single field using its $order property, then convert the command to use a notation command of the form "Do $cinst.$objs.myField.$enabled.$assign(kTrue)" to set the appropriate property.

If the command refers to a range of fields their $order property and the range does not exceed the threshold, then convert the command to use a appropriate command that refers to each field by $name.

For example "Enable fields OBSOLETE COMMAND 2 to 4" might be converted to "Enable fields {myField2,myField3,myField4}".

If the command uses an expression or a range that exceeds the threshold then convert the command to use a notation command of the form "Do $cinst.$objs.1001.$enabled.$assign(kTrue)" to set the appropriate property.

Complex Parameters

For command that use complex parameter, calculations, square bracket notation or a range of field numbers that exceeds the threshold, use a notation command of the form "Do $cinst.$objs.$sendall($ref.$visible.$assign(kFalse),($ref.$order>=lFromField)&($ref.$order<=lToField)"

In cases where only a complex "From" parameter has been used the notation command would be of the form "Do $cinst.$objs.$sendall($ref.$visible.$assign(kFalse),$ref.$order=lFromField)"

Assumptions

  1. That object names are unique within a class.

User Setup Required for this Module

  1. The variable "iExpandOrderLimit" that determines the threshold for converting commands that refer to a range of fields is preset to 20 (fields). You may wish to adjust the default value of this variable using the method editor variable pane.

Process any line of code found that contains one of these commands. The aim is to replace existing commands that use the $order property to reference a field with the name of the field.The command will be replaced by an equivalent notation command that sets an appropriate property to kTrue or kFalse.

If the command is "Show fields" or "Hide fields" then the property to be used is "$visible".

If the command is "Enable fields" or "Disable fields" then the property to be used is "$enabled".