Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

QQuestion: How can I remove an application function and replace calls to it with something different?

A: You can also try this:
In the <compile>Answer:

First of all, an option that should be considered is to keep your original calls as is, but to fine tune the implementation to use .NET by hand. Then, use a Author/Replace or related command to to swap in in your fine-tuned code.  

However, if you really want to change the calls, You may add some refactoring commands to your translation script.  In the <compile> section of the script, do a remove/remove-stubout with a migPattern.  This will rework the calls. Then, after the <analyse> <analyse> section, use refactor/remove-delete to remove the original.
Something like this.
Example1: Here is an example you can try using our ScanTool sample:

Code Block
<Compile Project="%SrcPath%">
<remove identifier="ScanToolLib.readNode" migStatus="stubout" migPattern="%1d.ReadXMLNode(%2d))" />
<Analyse />
    <remove identifier="ScanToolLib.readNode" migStatus="delete" />

Since the methods to be refactored were are in a module, it will not be in an IDF (unless you move the module using the SharedFile command) , so these rules will be needed for each VBP that uses the module – unless you moved the module to an IDF using the SharedFile command.Another option that is has some appeal is to keep your original application interface calls as is, but fine tune the implementation to use .NET by hand. Then, use author/replacefile to drop in your fine-tuned file. It really depends on what you were doing … and if you want to preserve the interface or not. JiraserverGreat Migrations LLCcolumnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolutionserverIdf53599a0-456c-3bb4-8f86-f0ce4f5bf78dkeyPWS-9 

Example 2: I have a Declare in a SharedFile, that I want to migrate to a Framework call:

Code Block
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sleep 500

We want no declaration and calls like this:


To make things more interesting this Declare was in a module that was shared throughout the system;  the declaration is being moved into a host project using the Shared

Code Block
<Compile Condition="%SrcName%=='AppCommon'">
      <Migrate id="GlobalDeclarations.Sleep" nPram="2" migName="System.Threading.Thread.Sleep" migStatus="external" />

Changes the calls in AppCommon as expected

The Migrate command also adds a migName to the FromCode IDF generated for the translation:

Code Block

      <method id="Sleep" migName="System.Threading.Thread.Sleep" type="Void">
         <argument id="dwMilliseconds" type="Integer" status="ByVal"/>

The migName attribute alters calls made to the method the codes that reference AppCommon.DLL.

Note that in this case, a "migrated" declaration is authored in the generated DLL code; it must be removed with an Author\Fix.

Code Block
<Author Condition="%SrcName%=='AppCommon'">
<Fix host="%SrcName%" name="PostEdit">
   <Replace name="Remove GlobalDeclaration.Sleep">
         public static extern void System.Threading.Thread.Sleep(int dwMilliseconds);

Note: The XML above uses the Condition attribute of the ScriptRules feature.