Hello,
As I understand that the current working directory of the simulation is the same as the model directory. I try to load data in a parent directory in external C++ functions, forexample "..\data\file1.dat". My question is whether the reference to the parent directory of the current model, i.e. "..\", valid in external functions. It seems that I can do this in previous Vensim version but not the current version 6.0.
Thanks
Model working directory
Re: Model working directory
I'd suggest to use the absolute path of the current directory. As I remember you can add the relative to that as well (e.g. D:\MyProject\Model\..\data\file1.dat)
Check the vensim_get_info function in the DSS doc.
However, I don't know if the get_info has proper results in version 6.0. I have only a 5.11 license, in that it does.
Check the vensim_get_info function in the DSS doc.
Code: Select all
char curr_dir[MAX_LEN];
(*VENGV->get_info)(4, curr_dir, MAX_LEN);
Re: Model working directory
We haven't changed anything about external functions in 6.0 so whatever worked before should still work - if not, an example might help us diagnose the problem.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Model working directory
Hi etam and tomfid,
I am sorry for the late response. I can use the relative path in the external dll when I run the model directly in Vensim. However I cannot read or write to files when I run the same model under Vensim dll. Please find attached my example, adapting from Vensim's samples. The WORLDAPP.vmf model uses the external PSUM function in VENEXT.C. In the PSUM function I print out the current directory to a file. This works when I run it directly. Then I publish the model to WORLDAPP.vpm and run it through the Vensim dll sample 'C:\Documents and Settings\All Users\Vensim\dll\csharp\VensimDemo'. This time it doesn't print the current directory to a file but it does produce the output current.vdf. Does this means that Vensim dll ignore my code to print out to a file, both absolute and relative paths?
Thanks for your quick responds
I am sorry for the late response. I can use the relative path in the external dll when I run the model directly in Vensim. However I cannot read or write to files when I run the same model under Vensim dll. Please find attached my example, adapting from Vensim's samples. The WORLDAPP.vmf model uses the external PSUM function in VENEXT.C. In the PSUM function I print out the current directory to a file. This works when I run it directly. Then I publish the model to WORLDAPP.vpm and run it through the Vensim dll sample 'C:\Documents and Settings\All Users\Vensim\dll\csharp\VensimDemo'. This time it doesn't print the current directory to a file but it does produce the output current.vdf. Does this means that Vensim dll ignore my code to print out to a file, both absolute and relative paths?
Thanks for your quick responds
- Attachments
-
- VENEXT.zip
- (10.76 KiB) Downloaded 202 times
-
- WORLDAPP.vmf
- (53.7 KiB) Downloaded 194 times
-
- Super Administrator
- Posts: 4613
- Joined: Wed Mar 05, 2003 3:10 am
Re: Model working directory
Have you loaded the external function library?
I'm writing on a phone, but you need to specify the external function lib in an ini file, and then call the loadini venapp command to load it.
I'm writing on a phone, but you need to specify the external function lib in an ini file, and then call the loadini venapp command to load it.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Model working directory
That's my fault, I forgot to load the external dll. I fixed it and it works now.
Many thanks
Many thanks