int run_cpp(string directive, ...)

Runs another script from the current one.
Using these functions, you can create "on the fly" scripts of any complexity, as well as run with different initial values of the arguments;
After executing another script, the execution of the current script continues.
Returns the value that the running script issued in the return command (for example, 0, if it was return 0;).
The text of the script for execution can be created directly during execution of the current script and written to a variable of type stging.
Then you can run it directly from this variable.
At start it is possible to use incoming parameters - an integer, a real number and a string.
Directives and their meanings are listed below.

run_from_file   run the script text from the file, with specified arguments
run_from_variable   run script text from a string variable, with arguments
get_args   get arguments that were set when the script was run

run_from_file

Command fotmat:

int run_cpp("run_from_file", string filepath, int iArg1, double dArg2, string sArg3);

A script is run from the filepath file (the full path to the file is specified).
To execute the file, the arguments iArg1, dArg2, sArg3 are specified.
Values of the arguments can be obtained during the execution of the file.

Example. Run the script for execution from the file my_prg_script.cpp, located in the directory "C:":

string filepath = "C:\\my_prg_script.cpp";
int ivariant=2;
int res = run_cpp("run_from_file",filepath,ivariant,0,"");

run_from_variable

Command format:

int run_cpp("run_from_variable", string script_text, int iArg1, double dArg2, string sArg3);

A script is run in the string variable script_text.
To execute the file, the arguments iArg1, dArg2, sArg3 are specified.
The values of the arguments can be obtained during the execution of the script from the string.

Example. Create the program text in the string variable my_script_variable and run it for execution.

string my_script_variable = "int main(){";

my_script_variable += "cout << \"This text is executed\"";
my_script_variable += "}";
int res = run_cpp("run_from_variable",my_script_variable,0,0,"");

get_args

Command format:

int run_cpp("get_args", int &iArg1, double &dArg2, string &sArg3);

During the execution of the script, it reads the values of the arguments specified at its start by the directives run_from ....

Example. Get the arguments specified when running the script in variables and display their values in the message window.
iint iArg1;

double dArg2;
string sArg3;

int res = run_cpp("get_args",iArg1,dArg2,sArg3);
cout << iArg1 << " ," << dArg2 << " ," << dArg3 ;