Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »


1) Prepare an ServiceMethod_EditSource Handler in a gmSL script:

PreEdit.gmsl
int ServiceMethod_EditSource(int fileRoot)
{
   tInfoFile   fileInfo;
   Handle      textStream;
   int         rai;
   int         length;
   string      record;  
   int         nRecord;
   int         curRecord;
   int         iPos;

   fileInfo = Store.GetVector(fileRoot);
   if(fileInfo.textBase == 0) return 0;
   textStream = Text.Open(Store.GetHandle(),fileInfo.textBase);
   nRecord = Text.Maximum(textStream);
   curRecord = 0;
   while(curRecord < nRecord)
   {
      curRecord = curRecord + 1;
      Text.Position(textStream,curRecord);
      record = Text.Access(textStream, length, rai, 0);
      int curLen = sizeof(record);
      System.LogMessage(curRecord + "] " + curLen + ":  " + record);
      if(length < 27) continue;
      iPos = Character.FindFirst(record, 0, "If (Ctrl = vbChecked) Then");
      if(iPos == 0) continue;
      if(Select.Progress) System.LogMessage("Found 'If (Ctrl = vbChecked) Then' in <" + Store.GetIdent(fileRoot) + "> Record = " + curRecord);
      iPos = Character.FindFirst(record, 0, "Ctrl");
      record = Character.Insert(record, iPos+3, ".Value");
      if(Select.Progress) System.LogMessage("Fixed : " + record);
      Text.Position(textStream,curRecord);
      Text.Delete(textStream);
      Text.Position(textStream,curRecord - 1);
      Text.Insert(textStream, record);
   }
   Text.Close(textStream);
   return 1;
}


Then  hook the handler to a custom migration event prior to the compile:

<gmBasic>
...
<Refactor event="CSH">
   <gmSL NameSpace="CSH" Class="ServiceMethods" Source="..\usr\PreEdits.gmsl" />
</Refactor>
<Compile Project="%SrcPath%" >
</Compile>
...
</gmBasic>
  • No labels