gmplFixStatement

Fix Statement Summary

Fix is a nonterminal, command statement that occurs in command scripts and can also occur within Compile or Author statements. It is used as well with EditFile commands in GlobalSettings files. This statement supports making changes to the source code before it is compiled or target code before it is written. A source code fix does not change the original VB6 or ASP files; rather it changes the code in memory after it is read.


The attributes of the Fix statement are as follows:


Attribute Description
StatusThis optional attribute describes the status of the fix. The process of fixing codes often begins with a raw editing change which is then later replaced by either a refactoring upgrade or by a more generic specification for the compiler or analyzer. When this occurs the original raw fix specification can be assigned a status description which then leaves the specification as entered but which tells this statement to simply skip the entire specification. If status is specified and is not set to Active then the entire fix block is skipped.
HostThis optional attribute contains the fully qualified identifier of the project or page containing the text buffers to be fixed. The Host attribute can either specify that all projects/pages be included in the fix operation or that only one project/page be included. If the identified component is not present then the Fix is simply skipped; else only the text buffers associated with the indicated host are processed. If this attribute is omitted, then all text buffers in the scope of the command are processed.
TypeThis attribute contains one of the entries ReplaceGlobal or ReplaceSingle. The default is ReplaceGlobal which means that any matches and associated changes should be done for every occurrence in the set of text buffers in scope. The entry ReplaceSingle means to do it only once.
NameThis attribute names the overall fix specification. It is used to document the script itself and appears in any progress messages that are displayed.
LangThis attribute contains one of the entries: vbp, csproj, vbproj, vb7, vbn, csh, or all. The default is all. This attribute restricts the set of text buffers searched to those that are written in the indicated language. Note that vb7 refers to the combined VB6/ASP/VbScript source languages.
FileFilterThis attribute contains the name of a source file. It is used to restrict the fixes to a particular file within the set of files encompassed by Host attribute. If it is not present or if it is not within the scope of the restricted host then the fix is skipped.


The substatements of the Fix statement are as follows:


Substatement Description
TypeThis deprecated substatement can be used to change the active value of the Type attribute. It uses the syntax <Type>type value</Type>
NameThis deprecated substatement can be used to change the active value of the Name attribute. It uses the syntax <Name>name value</Name>
FileFilterThis deprecated substatement can be used to change the active value of the FileFilter attribute. It uses the syntax <FileFilter>filefilter value</FileFilter>
ReplaceFileThis substatement replaces an entire file in one or more of the text buffers.
ReplaceThis substatement replaces or deletes specified strings or blocks of code within the text buffers.


The script errors associated with the Fix statement are as follows:


Error Description
1016This Fix subcommand is not valid: %1d



ReplaceFile Fix Substatement Summary

ReplaceFile is a terminal substatement of the Fix statement. It replaces the content of files within the active text buffers with the content of a specified text file.


The attributes of the ReplaceFile substatement are as follows:


Attribute Description
TargetThis attribute contains the full pathname of the file containing the replacement records.
NameThis attribute can be used to change the active value of the Name attribute encompassing the process.
LangThis attribute can be used to change the active value of the Lang attribute encompassing the process.
SourceThis attribute contains a filename that cat statements within the active text buffers must match in order to trigger the replacement.


Text buffers contain multiple files each of which is started with a cat filename statement and ended with a terminal marker !)(!. The ReplaceFile substatement searches the active text buffers for cat statements whose filename matches the source attribute. For each one found, all records below the cat and above the !)(! are deleted. Then the records from the target file are inserted.

Replace Fix Substatement Summary

Replace is a nonterminal substatement of the Fix statement. It replaces or deletes either string fragments within text records or blocks of one or more records. When the fix type is ReplaceGlobal, then all matches in all active text buffers are processed. When the fix type is ReplaceSingle, once a match is found the process stops.


The attributes of the Replace substatement are as follows:


Attribute Description
StatusThis attribute can be used to change the active value of the Status attribute encompassing the process.
NameThis attribute can be used to change the active value of the Name attribute encompassing the process.
LangThis attribute can be used to change the active value of the Lang attribute encompassing the process.
CaseSensitive

Specifies that character comparisons are to be case sensitive

MatchBlockSpecifies that all lines must match exactly up to whitespace
MatchTillLastSpecifies that all lines match exactly except last line


The substatements of the Replace substatement are as follows:


Substatement Description
OldBlockThis substatement specifies the text that has to be matched to trigger a deletion or text substitution.
NewBlockThis optional substatement specifies the substitution text to be used if a match is achieved using the OldText. If this substatement is omitted, then a match on the OldBlock deletes that text.


The script errors associated with the Replace substatement are as follows:


Error Description
1013Replace missing initial OldBlock command, encountered: %1d
1014Replace missing NewBlock command, encountered: %1d
1015Replace missing End Tag, encountered: %1d


There are two forms that can be used for specifying the text blocks. The single line form is


    <OldBlock><![CDATA[...oldtext...

The multi line form is


    <OldBlock><![CDATA[
    ...oldline 1...
        ...
     ...oldline n...

    

There is no requirement that the two forms match in a given replace. In all cases leading and trailing whitespace is ignored and the comparisons are not case-sensitive. Single line matchs replace or delete substrings within lines and may work on multiple matching substrings on the same line. Multiple line matchs work on entire lines.


There is a special wildcard notation "..." available for use in the multi line form of the OldBlock specification that means "skip records until match is found". For example the following specification


<Fix>
   <Type>ReplaceSingle</Type>
   <Replace name="Remove duplicate function">
   <OldBlock><![CDATA[
   Private Function ComputeSomeThing
     ...
   End Function
   

will remove the first occurrence of the function "ComputeSomeThing". The ... must be the only entry on the line and it may be neither the first nor the last line of the specification. Once the starting lines are matched, records are skipped until a record matching the following line is found.

"Top-Level" Fix

Fix statements typically occur in as a child-element in a Compile, Author, or EditFile blocks.  However, they may also occur as a top-level script command.  In this context, the Fix must also have a FileFilter attribute.  And, unlike the child-elements that work on a copy of the file in stored in system model in memory, top-level fixes modify the specified file directly.  


Table of Contents