...
No Format |
---|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Translation Log: C:\gmSamples\NewSamples\FileExplorerAPI\proj_csh\log\FileExplorer_csh-FileExplorer-gms-csh.TRAN.log ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Basic Processor V30.76(07/18/18) System Build(07/18/18 5:26:53) Processing file: C:\gmSamples\NewSamples\FileExplorerAPI\src\FileExplorer.vbp Reprocessing file: gm.cls Reprocessing file: gm.cls name=frmExploreLite.frm formFile.textBase=3838 textStream=4 record= Begin MSComctlLib.Toolbar Toolbar1 token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[Toolbar] lexeme=2 token=[Toolbar1] lexeme=2 record= Begin MSComctlLib.ImageList ilSmall token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[ImageList] lexeme=2 token=[ilSmall] lexeme=2 record= Begin MSComctlLib.ImageList ilMain token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[ImageList] lexeme=2 token=[ilMain] lexeme=2 record= Begin MSComctlLib.ListView lvListView token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[ListView] lexeme=2 token=[lvListView] lexeme=2 record= Begin MSComctlLib.TreeView tvTreeView token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[TreeView] lexeme=2 token=[tvTreeView] lexeme=2 record= Begin MSComctlLib.StatusBar sbStatusBar token=[MSComctlLib] lexeme=2 token=[.] lexeme=1 token=[StatusBar] lexeme=2 token=[sbStatusBar] lexeme=2 ... Translation Time (sec) = 0.25 |
Here is an example that edits files: adding a comment to lines in form files ending with ':'
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> |