Page 4 of 4

Posted: Wed Nov 17, 2010 11:37 am
by arraywanted
I am back with a new problem.

As you remeber, I managed to control Vensim via Matlab on a WinXP computer. Meanwhile, my intership came to an end, so I didn't work with Vensim for some time.

Now I tried again to call Vensim from Matlab on the same computer - and it does not work anymore. I simply cannot load any model, the LOADMODEL command just returns 0 without an window opening up or something like that.

It's quite similar to the situation on my Win7 computer (I explained before), only it did work on this one last time. I can't be completely sure that there hasn't been any modifiying on this computer; but what could anyone have done to cause this problem?

I tried reinstalling Vensim, but that does not help.

It is possible to load the DLL, I also can use the command 'vensim_check_status' (which returns 0), but I cannot load models - which means I can't work.

By the way, I searched for the vendll.err, but didn't find it. Where is it supposed to be on a WinXP computer?

Do you have any ideas? I virtually have no clue why this suddenly wouldn't work anymore.

Posted: Wed Nov 17, 2010 11:39 am
by arraywanted
There is a file named 'vensimdll.err'. Is that the same as vendll.err?
This file contains the following:

Vensim® DLL(Full) version 5.9e error log starting Wed Nov 17 12:27:15 2010
ERROR: Class °‡ without command.

Posted: Wed Nov 17, 2010 12:01 pm
by Administrator
Has Matlab been upgraded on the computer you are working on?

Posted: Wed Nov 17, 2010 12:41 pm
by bob@vensim.com
It looks like the strings being passed to the DLL are no longer valid. The DLL is getting "°‡ " instead of "SPECIAL>LOADMODEL..." Make sure that the string being passed is a null terminated single byte string with UTF8 encoding (or simply ASCII).

Posted: Wed Nov 17, 2010 4:39 pm
by arraywanted
No, Matlab has not been upgraded.

I can't imagine why the strings being passed would not be valid any more, since I did not change the subroutine I use to load models in any way. But I'll take a look at that, thank you.

I'd still appreciate other ideas, though... this is really important.

Posted: Tue Nov 23, 2010 9:06 am
by arraywanted
Thank you very much, Bob - your hint pointed in the right direction:

It made me check the function signatures of the library again, and - I have no idea why, maybe someone updated Vensim - they have changed. Previously, the function vensim_command e.g. needed the matlab type VoidPtr as input argument, and now it needs an simple string instead. After I changed all subroutines that used a VoidPtr it works again.

And the best thing is: After I found that out I suspected that this could be the problem with my Win7 computer as well - and I was right. It does now work there, too.

Funny story, though: Vensim was installed on both computers on the very same day - yet still the function signatures differed (well, until now - they're the same now). I cannot really make sense of that.

Re: Call vensim

Posted: Tue Sep 13, 2011 9:58 pm
by olive
Hi,
I have just seen your last post about loading a Vensim model into Matlab. I'm currently trying to achieve the same thing and noted your comment about the change in input arguments. I'm new to Vensim and have no experience using Matlab to interact with other applications. However, for my current project I need to be able to pass input values and run Vensim from Matlab, do some optimization based on the outputs (in Matlab) and run Vensim again with a different set of input values.

I think I was able to successfully load the Vensim dll but I have questions regarding loading a model. Here is the code I used:

Code: Select all

clear all

if not(libisloaded('VenDLL32'))
    hfile = ['C:\Documents and Settings\All Users\Vensim\dll\vendll.h'];
    dllfile = ['C:\Documents and Settings\All Users\Vensim\dll\vendll32.dll'];
    loadlibrary(dllfile,hfile);
end
libfunctionsview VenDLL32

str=['SPECIAL>LOADMODEL|C:\Documents and Settings\opinon\My Documents\MatlabResearch\rabfox.vpm'];
calllib('VenDLL32','vensim_command',str);

When i run it I get ans = 1. Does this mean that the model has been successfully loaded? I'm wondering because i was expecting Vensim to open or something.
If this is not what I should get, could you please tell me where my mistake is?
Thank you very much for your time and consideration.

Re: Call vensim

Posted: Wed Sep 14, 2011 8:15 am
by Administrator
When i run it I get ans = 1. Does this mean that the model has been successfully loaded?
Yes. A 1 indicates success.
I'm wondering because i was expecting Vensim to open or something.
You might just see the Vensim splash screen flash as the DLL loads, but you will not see Vensim itself.

Re: Call vensim

Posted: Wed Sep 14, 2011 7:21 pm
by olive
Great! Thank you very much!
Kind regards,
Olivia

Re: Call vensim

Posted: Sun Dec 18, 2011 8:12 pm
by Yoller
Hi,

I am trying to call Vensim from Matlab as well. However, I keep just getting 0 when using the loadmodel function (after having loaded the vensimdll32 library).

The .err file simply says 'Reinstall Vensim' and nothing else.

I reinstalled it but still it doesn't work.

Any suggestion?

Thank you all so much,

Stefano

Re: Call vensim

Posted: Sun Dec 18, 2011 8:35 pm
by Administrator
Can you post the code that you are using?

Re: Call vensim

Posted: Mon Dec 19, 2011 3:56 pm
by tomfid
The "Reinstall Vensim" message can happen if the .dll can't find its language resource files, which can happen if you have path issues or have copied the .dll to a nonstandard location. Usually this is resolved by reinstalling Vensim. What Vensim version, operating system, and paths are you using?

Tom

Re: Call vensim

Posted: Mon Dec 19, 2011 8:37 pm
by Yoller
tomfid wrote:The "Reinstall Vensim" message can happen if the .dll can't find its language resource files, which can happen if you have path issues or have copied the .dll to a nonstandard location. Usually this is resolved by reinstalling Vensim. What Vensim version, operating system, and paths are you using?

Tom
Thank you Tom!

I am using Vensim 5.9e, Windows 7 and Matlab R2011b(32bit). Should I put the .dll file in a specific folder?

Re: Call vensim

Posted: Mon Dec 19, 2011 8:39 pm
by Yoller
Administrator wrote:Can you post the code that you are using?
I am using a combination of the successfull Matlab functions that some users posted here. basically what olive posted a few months ago.

Re: Call vensim

Posted: Tue Dec 20, 2011 11:57 am
by Administrator
Yoller wrote:I am using Vensim 5.9e, Windows 7 and Matlab R2011b(32bit). Should I put the .dll file in a specific folder?
No. Leave it where it is by default or it will not load properly.
Yoller wrote:I am using a combination of the successfull Matlab functions that some users posted here. basically what olive posted a few months ago.
There is little we can suggest unless you can post the calls you are making. There may be something very obvious that is causing it to not work.

And have you got the Vensim DLL demos working? We discussed this via email but still don't know if you have successfully got one of them working yet.

Re: Call vensim

Posted: Tue Dec 20, 2011 12:52 pm
by Yoller
function loademo

if not(libisloaded('VenDLL32'))
hfile=[ 'C:\Users\Desktop\Vensim\Vensim\dll\vendll.h'];
loadlibrary('VenDLL32',hfile);
end

libfunctionsview VenDLL32

str=['SPECIAL>LOADMODEL|C:\Users\Desktop\Vensim\Vensim\dll\rabfox.vpm'];
calllib('VenDLL32','vensim_check_status')
calllib('VenDLL32','vensim_command',str)

Unfortunately I can't load any demos either.

Re: Call vensim

Posted: Tue Dec 20, 2011 4:59 pm
by Administrator
What happens when you try and run one of the demos? What error messages are you getting?