oModuleSuperAPI

Type: Object Super Class Parent Module: N/A

This object super class provides reusable methods for converter modules to utilize. In order to make use of these methods, modules and submodules should have their "superclass" property set to"oModuleSuper".

Methods provided

$construct

Saves the name of the module in iModule and if the object class is a submodule (characters 1-9 of its name = "submodule"), the name of the submodule in iSubmodule. Also defines the list iLstSearchText which a subclass can use to set up text strings to search for in methods.

Parameters

pModule Character If this is a submodule then contains the name of the parent module, otherwise empty

$run

If the subclass $construct method only set a value in iSearchText and the list of strings to search for in methods iLstSearchText is empty then iSearchText is added to iLstSearchText. A list lClasses of all programmable classes in the library is created. For each programmable class in turn the method $processClass is called passing a reference to the class to be processed, then the Save class command is used to write the class back to the library and free up memory.

Parameters

pRefLib Item reference Reference to the open library file to be processed

$processClass

Process a single programmable class or subordinate object within a programable class (e.g. window field). If the current object being processed pRefClass is a class (i.e. not an object within a class), then a list iLstObjects of all subordinate objects within the class is created. For each method belonging to the current object pRefClass that is being processed, the progress window is advanced and the method $processMethod is called passing a reference to the method to be processed. This method makes recursive calls to itself in order to process all subordinate fields, and fields located inside container fields (e.g. tab pane).

Parameters

pRefClass Item reference Reference to the class (or subordinate object within a class) 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. If $processLine returns a message then it will be added to the log. Finally, if any method line was modified by $processLine, the new code is used to replace the method in the library.

Parameters

pRefMethod Item reference Reference to the method to be processed.

$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. For each occurrence of the search text pSearchText, the public method specified in pProcessMethod will be called once passing the parameters pLine, pFixedMsg, pRefMethod, pLineNo, pSearchText, pRemoveFollowingBlankLines, pRemovePrecedingLines (see description of these parameters below). The public method pProcessMethod must exist in the module (which is a subclass of oModuleSuper). The public method pProcessMethod must return a value of kTrue if the method line is modified or kFalse if it is unchanged. This method will return a value of kTrue if the method line was modified by pProcessMethod. This method may be overridden to be replaced with your own code as required.

Parameters

pLine List Contains a single method line to be processed and returns the 'fixed' line. If this list is returned empty, then the original line of code in the method is deleted; if it contains a single modified line, then the line is replaced with the new code; if it contains more than 1 line, then the original line is replaced by the new lines.
pFixedMsg Character Returns details of the 'fix' carried out to be added to the log.
pRefMethod Item reference The method currently being processed.
pLineNo Long integer Original line number in the method of the current line being processed.
pSearchText Character The matched search text that was located in the method.
pProcessMethod Character The public method in the subclass module to be called to process this text.
pRemoveFollowingBlankLines Boolean If true then any blank lines immediately following this line are removed.
pRemovePrecedingBlankLines Boolean If true then any blank lines immediately preceding this line are removed.

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

Parameters

pLines List Contains all the lines for a method.
pLine List Contains the replacement line or lines or empty.
pLineNo Long integer Original line number in method of current line being processed.
pRemoveFollowingBlankLines Boolean If true then any blank lines immediately following this line in the method are removed.
pRemovePrecedingBlankLines Boolean If true then any blank lines immediately preceding this line in the method are removed.

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

Parameters

pRefMethod Item reference Reference to the method to get.
pLines List Used to return the method code lines.
pLineText Character Used to define the list column to contain each method line.
pLineNo Long integer Used to define the list column to contain the line number.

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

Parameters

pRefMethod Item reference Reference to the method whose code is to be replaced.
pLines List Contains the new code method lines to be placed in the method.

$deleteMethod

Delete all code method lines from the indicated method pRefMethod. All Local and Parameter variable definitions will remain intact.

Parameters

pRefMethod Item reference Reference to the method whose code is to be deleted.

$end

Called once at the end of processing of a library. This performs no-op but can be overriden in subclass. Used to perform any required tasks at end of processing, for example completion of log entries.

Parameters - None

$addMethod

Check that specified method exists in class. If not add it as a new method returning a reference to the method in pRefMethod. If it is an existing method then return a list pLines containing the method code lines from the method.

Parameters

pRefClass Item reference Reference to the class containing method.
pMethodName Character Name of the method.
pRefMethod Item reference Returns a reference to the method.
pLines List Used to return the method code lines if it is an existing method.
pLineText Character Used to define the list column to contain each method line.
pLineNo Long integer Used to define the list column to contain the line number.

$createClassVars

Create class and instance variables for target class that are identical to those in source class.

Parameters

pSourceClassRef Item reference Class containing variable definitions to be copied.
pTargetClassRef Item reference Class where new variable definitions are to be created.

$createMethodVars

Create local and parameter variables for target method that are identical to those in source method.

Parameters

pSourceMethodRef Item reference Method containing variable definitions to be copied.
pTargetMethodRef Item reference Method where new variable definitions are to be created.

$createVar

Create variable for specified object of type indicated by parameters.

Parameters

pObjRef Item reference Reference to object for which variable is to be created.
pVarName Character Name of new variable.
pVarType Character Type of new variable ('$lvardefs', '$cvardefs', '$ivardefs', etc.)
pVarDataType Character Data type of new variable.
pVarSubType Character Data subtype of new variable.
pVarLength Integer Length of character variable.
pVarInitValue Character Expression to be used as initial value of variable.
pVarParmNum Integer Parameter number for paramater variables.

$lookupObjName

Lookup a field on a window class using dataname, tab order or ident and return the object name.

Parameters

pRefMethod Item reference Reference to the method whose code is to be deleted.
pLineNo Long integer Original line number in the method of the current line being processed.
pFieldId Character Dataname, tab order or ident of field to be looked up.

$lookupVarName

Look up a variable on a window class using dataname and return information about the variable (data type etc.)

Parameters

pRefClass Item reference Reference to the class currently being processed.
pDataname Character The name of variable to be looked up.
pErrorActionMsg Character The action to be performed if no variable with corresponding name pDataname can be found.
pVariableDataType Character Used to return the data type of variable.
pVariableDataSubtype Character Used to return the data subtype of variable.
pVariableType Character Used to return type (i.e. scope) of variable. e.g. class variable, file class etc.

$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//

Parameters

pItem Character Text of notation item to be checked (e.g. "myWindowClass")

$analyzeMethodStructure

Receives a method in the form of a list and returns the block structure of the method as extra columns

Parameters

pLines List Contains the method lines.

$nextExecutableLine

Return next executable line in method after current line. Lines that do not need to be executed are ignored. Note that the method must have been previously processed by $analyzeMethodStructure.

Parameters

pLines List Contains the method lines.
pNextExecutableLine Integer Used to return the number of the next executable line in the method.

$parseExpression

Parse an expression and return a list of variables and constants and their position in the expression.

Parameters

pExpression Character The expression to parse.
pVarList List Used to return the variable list, name or value in column 1 and position in column 2.