Hi,
I have from time to time done some simple GUI programming for Vensim models using Visual Basic and VENDLL32.DLL. In other contexts I have been using a tool called PowerBuilder (from Sybase) for database application development. Today I did a simple experiment to see if it was possible to use PowerBuilder together with Vensim. I did a quick and dirty copy and paste of external function declarations (with some minor changes). Most of the functions I tested (like: vensim_continue_simulation, vensim_start_simulation, vensim_finish_simulation) seemed to work, giving meaningful return values. One quite essential function, vensim_command, did anyhow only give me a return value of 0.
Is it in any way possible to make this work, or should I just give up trying?
Using the vendll32.dll
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Hi
FUNCTION int vensim_command(string kom) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_be_quiet(long quietflag) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_get_info(int infowanted, string beskr, int lengde) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_start_simulation(int loadfirst, int game, int overwrite) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_get_val(string varname, double varval) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_continue_simulation(int stepp) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_finish_simulation() LIBRARY "VENDLL32.DLL"
and then:
result= vensim_command("SPECIAL>LOADMODEL|test3.vmf")
returning 0
result= vensim_start_simulation(1,0,1)
returning 1
result= vensim_continue_simulation(10)
returning 1 ten times then 0
result= vensim_finish_simulation()
returning 1 and a new vdf-file was created in the default directory.
It looks like I have run vensim without a model(!?) because the vdf-file do not have any refrences to a model...
Morten
FUNCTION int vensim_command(string kom) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_be_quiet(long quietflag) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_get_info(int infowanted, string beskr, int lengde) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_start_simulation(int loadfirst, int game, int overwrite) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_get_val(string varname, double varval) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_continue_simulation(int stepp) LIBRARY "VENDLL32.DLL"
FUNCTION int vensim_finish_simulation() LIBRARY "VENDLL32.DLL"
and then:
result= vensim_command("SPECIAL>LOADMODEL|test3.vmf")
returning 0
result= vensim_start_simulation(1,0,1)
returning 1
result= vensim_continue_simulation(10)
returning 1 ten times then 0
result= vensim_finish_simulation()
returning 1 and a new vdf-file was created in the default directory.
It looks like I have run vensim without a model(!?) because the vdf-file do not have any refrences to a model...
Morten
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
Hi,
The last information did put me on track .
There are probably better ways to do this but this PowerBuilder code did function:
B=Blob("SPECIAL>LOADMODEL|C:\Data\MindLabAS\Prosjekter\AST\08Test\test3.vpm ",EncodingUTF8!)
kom=string(B)
result= vensim_command(kom)
As you can see I also had to save the model as a package..
Thanks a lot!
Morten
The last information did put me on track .
There are probably better ways to do this but this PowerBuilder code did function:
B=Blob("SPECIAL>LOADMODEL|C:\Data\MindLabAS\Prosjekter\AST\08Test\test3.vpm ",EncodingUTF8!)
kom=string(B)
result= vensim_command(kom)
As you can see I also had to save the model as a package..
Thanks a lot!
Morten