Versions Compared

Key

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

...

Decompiling Microsoft.VisualBasic.dll shows that VBNET.Strings.Len is heavily overloaded with separate versions for the .NET
primitive types and an overload for type object that handles with the case of x being an instance of a struct. 
All of the overloads of Len handle the case where x == null; for example, the overload of Len for string is shown to the right:

Code Block
public
 static 
 static int
 
 Len(
string Expression)
{
    if (Expression == null)
    {
        return 0;
    }
    return Expression.Length;
}
string Expression)
 {
     if (Expression == null)
     {
         return 0;
     }
     return Expression.Length;
 }

 


 

You can use gmStudio’s reporting tools to see how your application uses the Len function.  The Source Scan Report can be run from the Search panel or the Reports menu.  Simply searching for “Len” will show were you use Len, but may also show some false matches.  A more precise Source Scan Report can be done using a more sophisticated regular expression; for example “@\bLen\(“ (the leading @ indicates case-sensitivity).  The most precise report for how and where you use Len will be obtained by running the Analytics References Report.  See the records in the Analytics References report having MemLibr=Basic,  MemClas=Vb6Function, and Memname=Len.

...

The results show us that the rule for Len is in the VBASIC.xml file, which is located in the gmStudio installation folder, [installdir]\support\trancfg\lang.    The actual text of the rule for Len in VBASIC.xml looks like this

Code Block
<MetaLanguage>

...

 <patterns>

    . . .

...


 <patterns>
    . . .
    <pattern id="VBF">

...


      <subcode id="Len">

...


         <vbn narg="1" code="Strings.Len(%1d)"/>

...


         <jvs narg="1" code="len(%1d)"/>

...


         <csh narg="1" code="VBNET.Strings.Len(%1d)"/>

...


      </subcode>

 

In order to make gmStudio author x.Length instead of VBNET.Strings.Len(x) we will change VBASIC.xml so that 

<csh narg="1" code="VBNET.Strings.Len(%1d)"/>

...

<csh narg="1" code="%1d.Length"/> 

%1d is a place holder for the expression that was being passed into Len in the original VB6 code.  Internally it corresponds to the first expression on the operation stack built by gmStudio when it processes and stores the VB6 code. 

...

From time to time a new release of gmStudio will include changes to the default metalanguage scripts.  These changes will be baked" into the system default metalanguage file (vb7lang.vbi) and will be used by default in new translation workspaces. However, if you have a workspace that is using a project-specific metalanguage configuration, you will have to sync MUST sync up your custom metalanguage scripts to be compatible with gmStudio failing to do this will frequently cause the translator to terminate abnormally lead or produce malformed results.

Syncing up your custom metalanguage scripts to be compatible with gmStudio according to the following stepswith the new system defaults is the same as any other code merging operation:

For each of new system default filesscripts, check to see if you are using a custom script in your project workspace.

...

.  If you are not using a custom script, move onto the next script.  But, it you have have a custom copy of a script, merge the new system default into your custom copy.

...

The easiest way to do this is with a file comparison/merge tool such as Beyond Compare.

...

 Once you have synced all of your custom metalanguage scripts with the new system default script, you should rebuild your project specific metalanguage file using the Settings form.

Warning

Be careful not to change the system default files when you are doing the merge.

Your solution configuration should always be kept under version control, but you may also want make a local backup of your project-specific files before starting the merge so you can use it to restart if you make a mistake and to double check your work. Your migration

...