Executes software and scripts outside the LayoutEditor. More...
The process class contains several commands to control external software tools. The started tool can run independend of the LayoutEditor, or the execution of the macro can wait on the result of the external tool. Also an interface to start external LayoutScript is supported.
Also reading and writing environment variable can be done with this class.
command is executed with the given arguments. It waits until command terminates and the exit code is returned. If arguments is a string it is split on spaces to a stringList.
A TCL command is executed and its output returned. (introduced with release 20200214)
string s=process::executeTcl("puts $application\n");
searches and executes the tool name with parameter. path is a hint where to find the tool. callback macro is called as soon the tool finished. The method will return immediately and does not wait until the started tool terminated. true is return, if the tool was started successfully.
If the optional parameter triggerOnOutput is set to true, the callback macro will be regulary called when the executed tool write to the output. (option introduced with release 20190919)
#!/usr/bin/layout
#name=start bash script
#help=start bash script with callback macro
int main(){
file f;
string path=f.currentPath();
stringList sl;
sl.append(path+"/script");
sl.append(layout->filename);
if (process::externalTool("/bin","bash",sl,path+"/callback.layout")) {
layout->showStatus("bash script started");
} else {
layout->showStatus("failed to start bash script");
}
}
Returns: the commandline parameter the LayoutEditor was started with.
Returns: the environment variable parameter
layout->showMessage("your home path",process::getEnv("HOME"));
Returns: true if the LayoutEditor was created for Linux
Returns: true if the LayoutEditor was created for Mac OSX
Returns: true if the external process started before with the externalTool command is still running. toolName must be identical with the name used when calling the process. (introduced with release 20190923)
Returns: true if the LayoutEditor was created for Microsoft Windows
set the environment variable parameter to value
opens a browser with the url.
#!/usr/bin/layout
#name=open browser
#help=open browser with the LayoutEditor docmentation
int main(){
if (!process::openBrowser("https://layouteditor.org")){
layout->showStatus("browser not found");
}
return 0;
}
Starts a Python script with parameter args.
Starts a TCL script.
Terminates the external process started before with the externalTool command. toolName must be identical with the name used when calling the process. (introduced with release 20190923)
Returns: the new output text to the command line since the last callback call, if the macro is a callback of an externalTool command (see above). In all other cases an empty string is returned. (introduced with release 20190919)
Returns: the output to the command line, if the macro is a callback of an externalTool command (see above). In all other cases an empty string is returned.
#!/usr/bin/layout
#name=callback macro
#help=callback macro to show output in the TextEditor
int main(){
string s=process::toolResult();
if (s.size()>1){
textEdit *te=project::getCentralTextEditor();
if (te->drawing->text()!="") {
te->newFile();
te->setFile(te->countFiles()-1);
}
te->setText(s);
te->drawing->title="Command Line Output";
te->drawing->setModifySaved();
}
return 0;
}
Returns: the event triggering the macro execution, if the macro is a callback of an externalTool command (see above). Possible values are output and completed. (introduced with release 20190919)
command is executed with arguments. It returns true, if the program launch was successful. If arguments is a string it is split on spaces to a stringList. There is no control on the started process. Use the externalTool feature , in case the process needs to be controled.