- allow scriptcontext objects to be dynamic

- enhancements in scriptcontext (error messages stored as properties)
This commit is contained in:
zolliker
2009-02-19 13:30:32 +00:00
parent 981534624f
commit 35f2b6b810
33 changed files with 753 additions and 310 deletions

View File

@@ -485,7 +485,6 @@ int SicsPrompt(SConnection * pCon, SicsInterp * pSics, void *pData,
/*----------------------- get object descriptor name -------------------------------
get the name of the object descriptor
*/
int SICSDescriptor(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
@@ -517,3 +516,44 @@ int SICSDescriptor(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, "notfound", eValue);
return 1;
}
/*------------------------------------------------------------------------*/
int SICSSilent(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]) {
Tcl_Interp *pTcl = NULL;
int iRet;
char *cmd;
char *result;
writeFunc oldWrite;
assert(pCon);
assert(pSics);
if (!SCinMacro(pCon)) {
SCPrintf(pCon, eError,
"ERROR: %s may only be called in scripts", argv[0]);
return 0;
}
pTcl = InterpGetTcl(pSics);
assert(pTcl);
if (argc < 3) {
SCWrite(pCon, "ERROR: should be: silent <error-value> <tcl-command>", eError);
return 0;
}
cmd = Arg2Tcl(argc-2,&argv[2],NULL,0);
assert(cmd);
oldWrite = SCGetWriteFunc(pCon);
SCSetWriteFunc(pCon,SCNotWrite);
iRet = Tcl_EvalEx(pTcl, cmd, strlen(cmd), 0);
SCSetWriteFunc(pCon,oldWrite);
if (iRet == TCL_OK) {
result = strdup((char *)Tcl_GetStringResult(pTcl));
SCWrite(pCon, result, eValue);
free(result);
} else {
SCWrite(pCon, argv[1], eValue);
}
free(cmd);
return 1;
}