Page tree
Skip to end of metadata
Go to start of metadata

Tran.xml

...

<Refactor event="CSH">
<gmSL NameSpace="CSH" Class="ServiceMethods" Source="..\usr\ServiceMethod_EditSource.gmsl" />
</Refactor>

<!-- COM REFERENCES -->

<Compile PageSlice="%VirtualRoot%\index.asp" >
</Compile>


ServiceMethod_EditSource.gmsl


int ServiceMethod_EditSource(int fileRoot)
{

   return 0; // off for now
   
   
   tInfoFile   fileInfo;
   Handle      fileStream;
   int         rai; 
   int         length;
   string      record;  
   int         nRecord;
   int         curRecord;
   int         iPos;
   int         iEnd;

   fileInfo = Store.GetVector(fileRoot);
   if(fileInfo.rawtext == 0) return 0;
   string fileName = Store.GetName(fileRoot)
   System.LogMessage("filename = " +  fileName);
   
   fileStream = Text.Open(Store.GetHandle(),fileInfo.rawtext);
   nRecord = Text.Maximum(fileStream);
   curRecord = 0;
   while(curRecord < nRecord)
   {
      // look for #include statements to be inlined to the code
      
      curRecord = curRecord + 1;
      Text.Position(fileStream,curRecord);
      record = Text.Access(fileStream, length, rai, 0);
      iPos = Character.FindFirst(record, 0, "<!-- #include file=");
      if(iPos == 0) continue;
      
      if(Select.Progress) System.LogMessage("INLINE " + record  + ">" + Store.GetIdent(fileRoot) + " @" + curRecord);

      // find the include file   
      
      string includePath = "C:\gmSpec\ASP\ScriptTagInclude\TestSite2\include.inc";
      int incRoot = System.LoadFile(includePath,1);
      if (incRoot == 0) return 0;

      // remove the include statement
      
      Text.Position(fileStream,curRecord);
      Text.Delete(fileStream);
      Text.Position(fileStream,curRecord - 1);

      // copy records from the include into the file text buffer

      Handle incStream = Text.Open(Store.GetHandle(),incRoot);
      int incRecords = Text.Maximum(incStream);
      int incRecord = 0;      
      for(incRecord = 1; incRecord <= incRecords; incRecord = incRecord + 1)
      {
         Text.Position(incStream,incRecord);
         string incText = Text.Access(incStream, length, rai, 0);
         Text.Insert(fileStream, incText);
      }
      Text.Close(incStream);      
   }
   Text.Close(fileStream);
   return 1;
}
  • No labels