Using External Functions with the Multicontext DLL

Use this forum to post Vensim related questions.
Post Reply
yobiman
Member
Posts: 30
Joined: Wed May 28, 2008 1:28 am

Using External Functions with the Multicontext DLL

Post by yobiman »

I am trying implement several external functions while using the multicontext dll (vendlstc.dll). Currently the external function is not working and I suspect it is because I haven't linked my external function to the appropriate .lib file. In the script for the external function I see the following instructions

When you create your external function library you need to link with the
.lib file associated with the program that will call your external functions.
For Vensim DSS this is vensim.lib. For the Vensim DLL it is vendll32.lib
and so on. If you do not do this loading the external functions will likely
fail, possibly with a message that the application is not properly installed.


However I am not sure what the .lib file is for the Multicontext DLL. Is it vendll32.lib?

Would greatly appreciate any assistance

Thanks
Phil
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Using External Functions with the Multicontext DLL

Post by Administrator »

Recent versions of the external function library do not need linking with vensim.lib any more.

What exactly is the error you are getting when trying to run a model with external functions? And are you applying a vensim.ini file (that loads the external functions) when loading the multi-context DLL?

Tony.
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
yobiman
Member
Posts: 30
Joined: Wed May 28, 2008 1:28 am

Re: Using External Functions with the Multicontext DLL

Post by yobiman »

The error log is recording the following error:
External function version mismatch need version 5860 (got 51050)

I have created a file called inifile.ini, which I have placed in the same directory as the .vpm model.
The inifile.ini has the following line:
ExternalFunctionLibrary=C:\wwwtr\vensimmodel\comp\Debug\venext6.dll

To load the model, I have the following commands:
string strModelPath = "C:\\wwwtr\\vensimmodel\\mobTraffSingSP.vpm";
string strVensimCommand = string.Concat("SPECIAL>LOADMODEL|", strModelPath);

int nResult = SimModel.VensimCCommand(VEFCC,strVensimCommand);
string strINIFilePath="C:\\wwwtr\\vensimmodel\\inifile.ini";

strVensimCommand = string.Concat(" SPECIAL>READINI|", strINIFilePath);

nResult = SimModel.VensimCCommand(VEFCC,strVensimCommand);


Thanks
Phil
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Using External Functions with the Multicontext DLL

Post by tomfid »

It sounds like you need to recompile your external functions with the latest headers etc. to match your dll version.
yobiman
Member
Posts: 30
Joined: Wed May 28, 2008 1:28 am

Re: Using External Functions with the Multicontext DLL

Post by yobiman »

Many thanks,
You're right, the problem was with the version of Vensim.h file I was using.
When I went back to an earlier version (which had the correct External Function version number) it worked
I suspect that the vendlstc.dll file that I am using is from an 5.10d or possibly earlier. Would that cause the problem?

Thanks again
Phil
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Using External Functions with the Multicontext DLL

Post by Administrator »

>> I suspect that the vendlstc.dll file that I am using is from an 5.10d or
>> possibly earlier. Would that cause the problem?
Yes. The version number that the DLL asks for needs to be the same as the one supplied by the external function library (if that makes sense).

Tony.
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
yobiman
Member
Posts: 30
Joined: Wed May 28, 2008 1:28 am

Re: Using External Functions with the Multicontext DLL

Post by yobiman »

OK that makes sense. What is required to get the multicontext dll upgraded?
Thanks
Phil
Administrator
Super Administrator
Posts: 4592
Joined: Wed Mar 05, 2003 3:10 am

Re: Using External Functions with the Multicontext DLL

Post by Administrator »

Email me at vensim@vensim.com with your serial number.

Tony.
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
Post Reply