Versions Compared

Key

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

...

Code Block
<ScriptRules>
<ScriptRule id="PreEditor" Condition="%TaskTag% AND %SrcName%=='upg AND FileExplorer'">
<Option>
   <Load Project="%SrcPath%" SourceCode="on" />
    
   <gmSL namespace="gmSL" class="gm"><[CDATA[[
   void InspectCode()
   {
      int       levels(19);
      int       iRoot;
      tInfoFile formFile;
      Text      textStream;
      int       nRecord;
      int       curRecord;
      int       length = 0;
      int       rai = 0;
      string    record;
      string    token;
      int       lexeme;
 
      for(iRoot = Store.FindFirstChild(levels,0); iRoot != 0; iRoot = Store.FindNextChild(levels))
      {        
         if(Store.GetObjectType(iRoot) != ObjectType.FormFile) continue;
         string name = Symbol.FullName(iRoot,0);
         System.LogMessage("name=" + name);
          
         formFile = Store.GetVector(iRoot);
         if(formFile.textBase == 0) continue;
         System.LogMessage("formFile.textBase=" + formFile.textBase);
          
         textStream = Text.Open(Store.GetHandle(),formFile.textBase);
         System.LogMessage("textStream=" + textStream);
 
         // sample code changes lines ending with ":" to lines ending with ": 'TEST"
         nRecord = Text.Maximum(textStream);
         curRecord = 0;
         while(curRecord < nRecord)
         {
            curRecord = curRecord + 1;
            Text.Position(textStream,curRecord);
            record = Text.Access(textStream, length, rai, 0);
            
            if(length < 2) continue;
            string last = Character.SubStr(record,length-1,1);
            string colon = ":"; // if statement has issues with ":"
            if (last==":") 
            {
               // Inserts a record after the current record and sets Position to new record
               Text.Insert(textStream,record + " ' TEST");
               // reset position to original record
               Text.Position(textStream,curRecord);
               // delete original record
               Text.Delete(textStream,curRecord);
               continue;
            }
         }
         Text.Close(textStream);
      }
   }
   ]]></gmsl>
 
   <RunCommand id="InspectCode"  />
</Option>
</ScriptRule>
</ScriptRules>

add to script with

   <ScriptRule id="PreEditor" fileName="PreEditor.Rules.xml" />
   
   <Compile Resx="%ResxFolder%" />