The following is a code snippet from one of my utility functions. It illustrates redirection of output stored in a atring array " " to either the script window, a notes window or to a file.
Hope this helps ...
.....
switch (ControlID)
{
case IDC_RBN_Script_Window:
double dVal=LabTalk.type.redirection;
LT_execute("type -a ");
LT_execute("type.redirection=1");
for(int i=0;i<szOutPut.GetSize();i++)
{
strLine=szOutPut[i];
out_str(strLine);
}
LabTalk.type.redirection=dVal;
strTemp="Results Written to Script Window";
SetDataDisplayText(strTemp);
break;
case IDC_RBN_NOTEPAGE:
if(OutNote.IsValid()==false)
{
if(OutNote.CreateVisible(false)==false)
{
SetDataDisplayText("NotePageCreation Error ... Data Not Saved");
return (false);
}
}
int numLines=szOutPut.GetSize();
for(i=0;i<numLines;i++)
{
OutNote.AddLine(szOutPut[i]);
}
strTemp="Results Written to NotePage:"+OutNote.GetName();
SetDataDisplayText(strTemp);
break;
case IDC_RBN_FILE:
string strPath;
StringArray saFiletypes;
saFiletypes.SetSize(1);
saFiletypes[0]="[ASCII TEXT (*.TXT)] *.txt";
string strFilePath = GetSaveAsBox( saFiletypes );
if(strFilePath.IsEmpty()==false)
{
stdioFile TextFile;
if (TextFile.Open(strFilePath, file::modeCreate | file::modeWrite)==true)
{
for(int i=0;i<szOutPut.GetSize();i++)
{
strLine=szOutPut[i];
TextFile.WriteString(strLine);
}
TextFile.Close();
strTemp="Results Written to File: "+GetFileName(strFilePath);
SetDataDisplayText(strTemp);
}
}
break;
}
...