I have been playing around with the
CINT C interpreter and thought I would give it a try within ScriptBasic.
PRINT "Hello "
x = EXECUTE("cint world.c",-1,p)
#include <stdio.h>
main() {
printf("World");
}
Output:C:\scriptbasic\test>hello
Hello World
C:\scriptbasic\test>
Q. Can you pass variables to your C program and get the results of the C program returned back to the ScriptBasic program in a string?
A.If the number of variables you want to pass are many, build the C program dynamically in SB and write it to a file with the embedded SB variable values as C constants. (the SB constants could be an #include file as well) If you only need to pass a couple values, then add them to the EXECUTE(cint pgm arg) and extract them from the C program's command line argument when it runs.
To return results back to SB, you need to redirect the output to a file and open it in SB after the C program runs and GET the results. If your going to use redirection or piping, you need to include the CMD processor in your EXECUTE statement.
x = EXECUTE("cmd /C \"cint your_pgm.c > results.out\"", -1, pval)