Home » Community » Newbie corner » send/receive arguments to console(cmd/terminal) in GUI app
Re: send/receive arguments to console(cmd/terminal) in GUI app [message #33191 is a reply to message #33076] |
Thu, 14 July 2011 14:49  |
dave
Messages: 14 Registered: July 2011
|
Promising Member |
|
|
local process is the way to go.
for example..
int SysConsole::System(const char *cmd)
{
if(!IsOpen())
Open();
list.Add(AttrText(cmd).SetFont(font().Bold()).Ink(LtBlue));
int ii = list.GetCount();
LocalProcess p;
if(!p.Start(cmd))
return -1;
String out;
while(p.IsRunning()) {
String h = p.Get();
out.Cat(h);
int lf = out.ReverseFind('\n');
if(lf >= 0) {
AddResult(out.Mid(0, lf + 1));
out = out.Mid(lf + 1);
}
ProcessEvents();
Sleep(h.GetCount() == 0); // p.Wait would be much better here!
}
out.Cat(p.Get());
AddResult(out);
ProcessEvents();
int code = p.GetExitCode();
if(code)
while(ii < list.GetCount()) {
list.Set(ii, 0, AttrText((String)list.Get(ii, 1)).SetFont(font).Ink(LtRed));
ii++;
}
return code;
}
regards
dave
|
|
|
Goto Forum:
Current Time: Sun Aug 24 21:31:24 CEST 2025
Total time taken to generate the page: 0.05035 seconds
|