Originally posted by pollyp
One thing I'd like to do is capture the script's output for processing within the native application -- how can I do that? Yes, I see the iStdO/I public prototypes and am guessing that they are part of the solution -- but how do I use them?
Below some code snippets showing how to forward the output to a file:
Code:
// CMyTester.h:
/**
* File handle to script output
*/
RFile iResultFile;
/**
* Interpreter
*/
CSPyInterpreter* iInterpreter;
// CMyTester.cpp:
// Redirects output, called by the interpreter:
int CMyTester::CallSTDO(const char *buf, int n)
{
TPtrC8 from((TUint8*)buf);
HBufC* tgt = HBufC::NewLC(n);
TPtr data = tgt->Des();
data.Copy(from.Left(n));
TInt pos = 0;
pTester->iResultFile.Seek(ESeekEnd, pos);
pTester->iResultFile.Write(from.Left(n));
CleanupStack::PopAndDestroy(); //tgt
return n;
}
// pTester is a pointer to CMyTester instance, this is needed for CSPyInterpreter
// instance to access the private file handle in CMyTester instance
pTester->iInterpreter->iStdO = (CallSTDO); //Forward IO