Initialize Octave process inside C++ program and write commands to the standered input -
i'm working on c++ project , need initialize octave process inside program , write octave commands octave standard input , results octave standard output , standard error.
i searched , found octave forge engine package job. couldn't find how use package. want execute simple command such 5+5 , answer.
is there way of doing using octave engine package or using other way.
first created qprocess using qt.
qstringlist arguments; arguments << "--persist"; //set arguments of octave process. --persist:go interactive after octave.setprocesschannelmode(qprocess::mergedchannels); //set process channel octave.start("/usr/bin/octave", arguments);//if octave has installed other directory should changed.
after able write standered input of octave process.
if(octave.state()==qprocess::starting){ octave.waitforstarted(); //todo:should set timeout , if timeout happens set error report. processwrite(command); } else if(octave.state()==qprocess::running){ //todo write code octave.waitforreadyread(1000);//wait until standered output ready if(command.isempty()){ return; } else{ command+="\n"; octave.write(command.toutf8()); } } else{ //todo: error reporting }
Comments
Post a Comment