|
<< Click to Display Table of Contents >> SYS |
![]() ![]()
|
The SYS statement provides access to the system shell (in Windows sometimes called the DOS prompt). Gekko will wait until the SYS statement finishes before it continues.
sys <MUTE> statements WORKING = foldername;
MUTE |
(Optional). With this option set, the system shell runs silently in Gekko. Alternatively, the system shell output (and error messages) is shown in the Gekko main window. |
WORKING |
(Optional). If set, the Windows system will use this folder as "starting directory" for the system process. For example, SYS 'dir' working = c:\tools; will show the contents of the c:\tools folder. If WORKING is not indicated, the Gekko working folder is used. |
statements |
A string with windows system shell commands. You may use SYS without arguments. In that case, the system shell opens up as a separate window. |
In general, the SYS statement returns the output of the system shell, for instance:
sys 'dir'; //shows the list of files in the working folder |
You can use the SYS statement for file managing:
sys 'copy file1.txt file2.txt'; |
or for more complex tasks or jobs
sys 'start /wait gnuplot p1.prg'; |
If you need to insert scalar values, just use {}-parentheses. For instance:
%name1 = 'file1'; |
To open up the system shell in a separate window for interactive use, call SYS without arguments.
sys; |
Note the use of single quotes when using SYS.
•To call R via SYS, use for instance sys '""C:\Program Files\R\R-3.6.2\bin\rscript.exe" --no-save "C:\Gekko\Files\test.r""';
•To call Python vis SYS, use for instance sys '""c:\Program Files\Python36_64\python.exe" -u "C:\Gekko\Files\test.py""';
The use of "-quotes makes it possible to use blanks etc. in the file paths. When called like this, both R and Python will return screen output to Gekko while the R/Python program runs.