Type: | Module | Parent Module: | N/A |
This module converts OMNIS 7 event handling which uses $v3events to the OMNIS Studio paradigm. For example "If #AFTER" is converted to "On evAfter" etc. We will attempt to resolve certain configurations like "If #AFTER&NOT(#CANCEL)" but some that cannot be easily restructured will be logged as user fix errors.
This module only processes field and window $event methods. When one of these is encountered then the method code is searched for occurences of the OMNIS 7^3 event messages #AFTER, #BEFORE, #CLICK etc.
If the command which contains the message is not an "If", then this is logged as a user fix error.
If the message variable is located in a field $event method:
In cases where an "If..." command is replaced by "On ev...", the matching "End if" command is removed.
For example: | If #AFTER |
is converted to: | On evAfter |
and: | If #AFTER|#CLICK |
is converted to: | On evAfter,evClick |
and: | Else If #BEFORE |
is converted to: | On evBefore |
and: | If (#AFTER|#CLICK)&x=y |
is converted to: | On evBefore,evClick |
If x=y ;; this part is moved to the following line | |
and: | If AFTER&#CLICK|x=y |
is not converted |
If the message variable is located in a window $event method:
If the code is not an "If..." or or "Else If...", then a user fix error is logged.
Certain message variables are preprocessed to convert to use Studio pNextCode parameter.
Then the module needs to figure out whether the event in question is a field or window level event.
Note that this approach may lead to problems if a field event handler calls another method of the window class to detect field level events. For example the called procedure may contain "If #CLICK...some code...End if" commands, containing some code to deal with the click. In this case since #CLICK is a field level event, the code will be moved to the $control method and the processing will be applied to all fields on the window rather than just the originally intended field. This situation should be remedied in the OMNIS 7 code by moving the code that detects the event to the field procedure. So for the example above the "If #CLICK" and "End if" should be moved to the field procedure, and the "some code" bit left in the called procedure.
If more than 1 class method has code that detects events, then a warning that there is more than 1 Window Control Method in the class is displayed in the log.
Lines containing "SNA..." commands are converted to an appropriate "Queue..." event command and a "Quit event handler (Discard event)" command added to the next line. If there is no equivalent Studio command then a user fix error is logged.
When processing a "SNA set current field" command the method $lookUpObjName is used to convert the dataname or field number from the original command to the object name.
Lines containing "Set window control method OBSOLETE COMMAND" are removed.
Lines containing "Set task control method OBSOLETE COMMAND" or "sys(84)" function are logged as user fix errors.
If while processing an event block any nested checks for the same event are located (e.g. "If #CLICK" inside another "If #CLICK") then this is converted to test "pEventCode" instead (e.g. "If pEventCode=evClick" inside "On evClick").
Any duplicate "Quit event handler (Discard event)" (i.e. one immediately followed by another) or "Quit method" following "Quit event handler (Discard event)" are removed.
Any commands that follow a "Quit event handler" command are moved so that they precede the "Quit event handler" if possible. This is done because those commands would not otherwise ever be executed. This is not applied to commands that occur outside of the code block. If an "End if" or other command that delimits a code block is encountered following a "Quit event handler" command, then it is not moved since this would affect the logic flow.
The library property $prefs.$v3events is set to kFalse so that only the Studio event behaviour in enabled.
The following issues are not currently dealt with: