@mritter
This is not quite what you want but should help you get started.
The following is my function from SketchBlock fior launching arbitrary scripts. The first section is the part of interest is verifies the script is not intended as Rexx command and executes it via SystemTags() (that is indicated by an leading @ symbol which is an entirely custom thing for the sketchblock settings file, so ignore that bit).
Note that it duplicates the current Input() and Output() streams because SYS_Async,TRUE, means they will be closed.
void Executerexx(STRPTR cmd)
{
LONG rc,rc2;
STRPTR result = NULL;
STRPTR buffer = Dupstr(cmd,-1);
STRPTR p = buffer;
STRPTR q = p;
if(buffer)
{
while(q)
{
q = strchr(p,';');
if(q)
{
*q++ = '\\0';
}
if(*p == '@')
{
p++;
if(*p != '\\0')
{
BPTR in = IDOS->DupFileHandle(IDOS->Input());
BPTR out = IDOS->DupFileHandle(IDOS->Output());
if(0 > IDOS->SystemTags((CONST_STRPTR)p,
SYS_Asynch,TRUE,
SYS_Input,in,
SYS_Output,out,
TAG_DONE))
{
/* we failed so clean up dupped handles */
IDOS->Close(in);
IDOS->Close(out);
}
if(App->ap_MacroPython)
{
WriteApplicationMacroRaw(App,"\\n# ");
WriteApplicationMacroRaw(App,p);
WriteApplicationMacroRaw(App," \\n\\n");
}
else
{
WriteApplicationMacroRaw(App,"\\n/* ");
WriteApplicationMacroRaw(App,p);
WriteApplicationMacroRaw(App," */\\n\\n");
}
}
}
else
{
IIntuition->IDoMethod(arexxHost,AM_EXECUTE,p,SKETCHBLOCKPORT,&rc,&rc2,&result,NULL);
if(result)
{
#if REXXDEBUGLVL > 0
IDOS->Printf("result %s\\n",result);
#endif
}
if((strchr(p,':')))
{
if(App->ap_MacroPython)
{
WriteApplicationMacroRaw(App,"\\n# ");
WriteApplicationMacroRaw(App,p);
WriteApplicationMacroRaw(App," \\n\\n");
}
else
{
WriteApplicationMacroRaw(App,"\\n/* ");
WriteApplicationMacroRaw(App,p);
WriteApplicationMacroRaw(App," */\\n\\n");
}
}
}
p = q;
}
Freemem(buffer);
}
}
because the above Dups the Input/Output streams the if the scripts write to stsout then a the main prgrams console will open (if not open) and the output will appear there.
Sounds like you need a dedicated console for each laucnh script (like Workbench->Menu->Workbench->Execute command...)
So instead of duplicating the current input / output do
BPTR in = IDOS->Open("CON:x/y/width/height/Ouput Window/AUTO/CLOSE/WAIT",MODE_NEWFILE);
BPTR out = ZERO;
and use those in place of the in and out in the above code.
See con-handler.doc and the SystemTagList section of the DOS autodoc.
[edit]
The site code removed my \\ scapes from the code.
PS the outerloop that checks for *q == ';' is to allow execute of semi colon delimitered "one line scripts" and so may or may not be of use to you....
Edited by broadblues on 2016/11/6 18:23:04