To add a new Post-Conversion Module based on the superclass object oModuleSuper:
When the converter library is run your new post-conversion module will be called automatically.
The following reusable methods may be inherited from the superclass:
$buildAnalyzerDatafileList | Make a list of all the datafiles created by the O7Analyzer that can be found in the same folder as the library that is being converted. It is IMPORTANT to note that ALL analysis files need to be available in the SAME folder as the current library that is being converted because they may include external calls to this library. The list is sorted so that the library we are converting appears last in the list. This is to ensure that when we are processing the list the library that is being converted is processed last to ensure correct datafile is set after module completes. |
$construct | This method receives the item reference of the library to be processed as a parameter. If this parameter is empty then the $construct method quits, otherwise it builds a list of all method text strings "iLstSearchText" which this module will process (default is empty). If the module is being instantiated in order to call methods other than $run (for example by a module user interface window) then leave the library reference parameter empty. |
$run | Run this module for the specified library. The method "$processClass" will be called once for each programmable class in the library being processed. |
$processClass | Process a single programmable class or subrodinate object (e.g. a field on a window class.) The method "$processMethod" will be called once for each method in the class and also once for each field object owned by the current class. The recursive nature of these calls enables fields within containers (e.g. complex grids) to be processed. |
$processMethod | Process all method lines in the specified method. If the text contained in any line of the list "iLstSearchText" is found in the method text then the method "$processLine" will be called once for each line in the method that contains the text. The method text in the library will be replaced if any line in the method was modified. |
$processLine | Process a single line of the specified method. Correct any problems found in the code and return the new code in the list "pLine". The public method specified in "pProcessMethod" will be called once for each occurrence of the search text "pSearchText". The public method "pProcessMethod" must exist in the module which is a subclass of oModuleSuper. If the method line is modified, this method returns the value kTrue, if it is unchanged then the value kFalse is returned. This method may be overridden to be replaced with your own code as required. |
$replaceLine | Update the list "pLines" containing all the lines for a method, replacing the current line using the new method line or lines from a second list "pLine". If pLine is empty, then the original method line is deleted from pLines. If this leaves an empty reversible block then this is also removed. If pLine contains 1 line then the original method line is replaced by the new line. If pLine contains more than 1 line of code, then the original line is replaced by all lines from pLine. |
$getMethod | Return a list "pLines" containing the method code lines from the indicated method "pRefMethod". The first column of the list contains the method line text, the second column contains the original line number in the method. The list "pLines" must be empty and undefined prior to calling this method. |
$replaceMethod | Replace all lines in the indicated method "pRefMethod" with new code contained in the list "pLines". If the new method exceeds 500 lines then an error is logged. If an error occurs while replacing a method line, an error is logged together with an in-line comment containing a description of the error. |
$deleteMethod | Delete all code method lines from the indicated method "pRefMethod". All Local and Parameter variable definitions will remain intact. |
$end | Called once at the end of processing of a library. This performs no-op but can be overriden in subclass. |
$addMethod | Check that specified method exists in class. If not add it as a new method returning a reference to the method. If it is an existing method then return a list containing the method code lines from the method. |
$createClassVars | Create class and instance variables for target class that are identical to those in source class. |
$createMethodVars | Create local and parameter variables for target method that are identical to those in source method. |
$createVar | Create a variable for specified object of type indicated by parameters. Extra initialization lines may be generated where it is not possible to initialize a variable using the $objinitval property because it contains #???, these to be added to start of method. |
$checkNotationItem | Check notation item to see if it is valid. For example that it doesn't contain any invalid characters, i.e. "./" etc. Return corrected item. e.g. myFile.myField would be returned as //myFile.myField// |
$optimizeNotation | Substitute optimized code for certain notation items. |
$lookupObjName | Lookup a field on a window class using dataname, tab order or ident and return the object name. |
$lookupVariableName | Look up a variable in a class using dataname and return information about the variable (data type etc.). |
$lookupClassName | Return new name of class if it has changed during conversion. |
$lookupMethodName | Lookup a method name and return kTrue if found or kFalse otherwise. If the library name is not supplied then it defaults to the library being converted. You need to supply either the method number (old procedure number from Omnis 7.3) or the Omnis 7.3 procedure name or the new method name if the method was renamed by the O7Analyzer. If you supply the method name this may be either the original name of the method in Omnis 7 or a new name generated by the O7Analyzer. If the method number is supplied then the original method name and new name is returned. Nb. the name may have been modified by the O7Analyzer in event of bad characters being found. |
$removeUnusedVars | Remove any local or parameter variables that are not used in the method. Variables that, when deleted, cause "#???" to be introduced in method code are assumed to be used. Note that this approach may result in variables that are being used through non-tokenized references being deleted (e.g. Calculate x as [y] where y contains name of local variable 'z', then z is deleted.) |
$stripComment | Strip any in-line comment from a method line and return method line excluding comment. |
$addComment | Add an in-line comment to a method line and return new method line. |
$addClass | Add a new class to a library and return a reference to the new class. |
$analyzeMethodStructure | Receives a method in the form of a list and returns the block structure of the method as extra columns. |
$nextExecutableLine | Return next executable line in method after current line. Lines that do not need to be executed are ignored (e.g. comment lines, "End if", "End reversible block".) |
$openParamFile | Open the parameter file for specified library. If the file does not already exist then create it. If it is already open then set it as the current datafile. The parameter file is named OSP_YourLibraryName.df1 and contains library specific control parameters used by some converter modules. |
$closeParamFile | Close the parameter file for specified library. |
$moduleActive | Dummy method to indicate that the module is currently active. This method can be overriden in the subclass to return kTrue (module active) or kFalse (module not active). |
Any of the inherited methods may be overriden. However since much processing is often standard for each module, the most frequently overriden methods are:
$construct | To specify the particular method text string in "iSearchText" or, if 2 or more, in "iLstSearchText" which this module will process. |
$processLine | To specify the particular processing required for a method line containing the search text string. |
For information about adding new modules to the O$Converter see Adding a New Post-Conversion Module to 0$Converter.