Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Introduction to gmSL

The name gmSL stands for Great Migrations Scripting language. It is high-level programming language that is compiled and executed by gmBasic rather than compiled by the computer's processor as other programming languages (such as C and C++) are. Code written in gmSL can be embedded within gmPL scripts or can be in stand alone in source files with the extension gmSL. The gmSL language fully supports gmPL equivalents of the main line gmPL statements and can be used as a substitute for gmPL in most cases. gmSL is a procedural language and does not reproduce the gmPL declaration statements. The goal of gmSL is to enhance gmPL not to replace it.

First and foremost, gmSL is a compiled language. Its statements are converted into byte codes and those byte code are then either executed immediately or are saved to be executed at a later time. The byte codes themselves are 100% compatible with those used by gmBasic to compile the various source lanuages languages that it processes. The engine used to execute the byte codes is the same as the one used to evaluate constant expressions in source codes.

There are many contexts in which gmSL can be used to enhance an gmPL script. the following topics describe these contexts and are intended to serve as an introdution introduction to the capabilities of gmSL. The remainder of this manual describe the details of the language.

Embedding gmSL Expressions in gmPL Statements

The notation (%= ... %) is used.

Embedding gmSL Statements in gmPL Scripts

It is often convenient to be able to perform simple operations during the execution of a gmPL script that are not directly supported by gmPL. An easy way to do this is to embed gmSL statements in the script. The desired statements are enclosed within <gmSL> and </gmSL> tags. The statements themselves can be either a single statement that is executed immediately or a method definition that can then be executed later by the gmPL RunComand statement.

As a simple example consider the following script that translates a simple HashTable class.

Code Block
languagexml
themeEclipse
linenumberstrue


<gmBasic>
   <Storage Action="Create" Identifier="HashTable1" />
   <Select DevEnv="VS2013" Dialect="csh" BuildFile="local" />
   <Select System="\Manual\ScopeIssue\proj\idf\FromIdl" DeployLocation="C:\temp" />
   <Compile Project="\Manual\ScopeIssue\src\HashTable.vbp" />
   <Analyse />
   <Output Status="New" Filename="HashTable1.bnd" />
   <Author />
   <Storage Action="Close" />
 </gmBasic>
Everything goes well and the target code builds with no problems, but in examining that code

Code Block
languagecpp
themeEclipse
linenumberstrue


 int m_PrimaryIndex = 0;
 private int m_SecondaryIndex = 0;
 //  This variable is used to make the GetNextItem faster
 object m_GetNextValue = null;
 HashTableTyp m_HT = new HashTableTyp();
 public bool FindKey(string i_Key)
one wonders if it is possible to add the "private" modifier for some of the fields, that were declared with "Dim" in the original code instead of "Private".

There is presently no refactoring statement that can change the accessibility of a field to private; however, it can be done easily using embedded gmSL statements. Consider the following revised script.

Code Block
languagexml
themeEclipse
linenumberstrue


<gmBasic>
   <Storage Action="Create" Identifier="HashTable2" />
   <gmSL>System.LogMessage("Setting components to Private")</gmSL>
   <Select DevEnv="VS2013" Dialect="csh" BuildFile="local" />
   <Select System="\Manual\ScopeIssue\proj\idf\FromIdl" DeployLocation="C:\temp" />
   <gmSL>
   void MakePrivate(string identifier)
   {
      int iRoot;
      tVariable varInfo;

      iRoot = Symbol.FindIdentifier(identifier);
      if(iRoot)
      {
         varInfo = Store.DeltaVector(iRoot);
         varInfo.Private = True;
         System.LogMessage("Changed status of " + Symbol.FullName(iRoot,1) + " to Private") ;
      }
      else System.LogMessage("Could not locate " + identifier);
   }
   </gmSL>
   <Compile Project="\Manual\ScopeIssue\src\HashTable.vbp" />
   <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_PrimaryIndex" />
   <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_GetNextValue" />
   <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.HelpFile" />
   <RunCommand id="MakePrivate" Prams="HashTableProject.HashTable.m_HT" />
   <Analyse />
   <Output Status="New" Filename="HashTable2.bnd" />
   <Author />
   <Storage Action="Close" />
 </gmBasic>
The LogMessage is an example of the single statement form. The message will be displayed in the log file. Note gmSL does require a user storage area to compile; therefore, all such statements must follow gmPL Storage statement in the script.

The notation ... is used

The MakePrivate method is the one that will set the private attribute for the specified fields to true. It is this change that is needed so that the target declarations for these symbols will be "private". If the method finds the symbol whose fully qualified identifier is in the parameter identifier then it also logs a success message to the log file; else it logs a failure message. The RunCommand statement needed has its id attribute set to the name of the method and its Prams attribute set to the identifiers of the fields to be changed. Note that the HelpFile field does not exist. The resultant log file is as expected

Code Block
languagenone
themeEclipse
linenumberstrue


 Setting components to Private
 Changed status of HashTableProject.HashTable.m_PrimaryIndex to Private
 Changed status of HashTableProject.HashTable.m_GetNextValue to Private
 Could not locate HashTableProject.HashTable.HelpFile
 Changed status of HashTableProject.HashTable.m_HT to Private
Comparing the two translation bundles

Code Block
languagenone
themeEclipse
linenumberstrue


 ***** HashTable2.bnd
       }
       private int m_PrimaryIndex = 0;
       private int m_SecondaryIndex = 0;
 ***** HASHTABLE1.BND
       }
       int m_PrimaryIndex = 0;
       private int m_SecondaryIndex = 0;
 *****
 ***** HashTable2.bnd
       //  This variable is used to make the GetNextItem faster
       private object m_GetNextValue = null;
       private HashTableTyp m_HT = new HashTableTyp();
       public bool FindKey(string i_Key)
 ***** HASHTABLE1.BND
       //  This variable is used to make the GetNextItem faster
       object m_GetNextValue = null;
       HashTableTyp m_HT = new HashTableTyp();
       public bool FindKey(string i_Key)
does show that the accessibility of the three fields has been changed.

Writing Stand Alone gmSL Scripts

Stand alone files with the extension gmSL can be executed directly from the command line.

Embedding gmSL Methods in the Language File

Many of the operations performed by gmBasic can be specified using gmSL defined methods that are precompiled in the language file.

Embedding gmSL Methods in a Global Settings File

Operations to be performed by multiple translation scripts can be specified using gmSL defined methods that are precompiled in a global settings.

Overriding gmSL language Methods in gmPL Scripts

Any precompiled gmSL method in the language file can be overridden in a translation script.

Using gmSL to Author Control Properties

Special methods can be entered into library description files that author control properties.
Panel
bgColorCCFFFF
titleTable of Contents

Table of Contents