Page 1 of 1
How to get the name of the Run in visual studio 2008
Posted: Mon Jul 25, 2011 4:33 pm
by Paul Anim
Hi;
I want to be able to get the names of the Runs that I create during simulation.
Is there a way to get the run names of the simulation runs?
Help

Re: How to get the name of the Run in visual studio 2008
Posted: Mon Jul 25, 2011 5:48 pm
by Administrator
How are you creating the runs? If you are using a FileOpenDialog, just store the filenames returned from that.
Or if you want all .VDF files in a directory, there are plenty of free code examples on the web showing how to do that.
Re: How to get the name of the Run in visual studio 2008
Posted: Tue Jul 26, 2011 11:11 am
by Paul Anim
Administrator wrote:How are you creating the runs? If you are using a FileOpenDialog, just store the filenames returned from that.
Or if you want all .VDF files in a directory, there are plenty of free code examples on the web showing how to do that.
Hi,
On my interface, I have a button which uses "vensim_command("SIMULATE>RUNNAME|? Enter a new run name") to create a new run.
I also have another button which uses "vensim_command("MENU>LOAD_RUN|?")" to load runs for simulation. I want to be able to get the names of the loaded runs during simulation.
Is there any vensim command that can be used to list or display the current loaded runs.
I could have say 5 runs created but may load 3 of them. So i will like to be able to get the names of the loaded run.
Re: How to get the name of the Run in visual studio 2008
Posted: Tue Jul 26, 2011 11:19 am
by Administrator
ok, use the vensim_get_info function, you can get the list of loaded runs using that.
Re: How to get the name of the Run in visual studio 2008
Posted: Tue Jul 26, 2011 1:34 pm
by Paul Anim
Administrator wrote:ok, use the vensim_get_info function, you can get the list of loaded runs using that.
Hi,
Can you help me with the use of the vensim_get_info?
When i tried the code below, a value of 22 is displayed in the textbox .
Private Sub cmdInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInfo.Click
Dim inforesult As Object
Dim bb As String
bb = "test"
inforesult = vensim_get_info(10, bb, 500)
txtInfo.Text = inforesult
End Sub
What could be wrong with the code?
Help
Re: How to get the name of the Run in visual studio 2008
Posted: Tue Jul 26, 2011 8:18 pm
by Administrator
I'd suggest having a good look at Excel 97 example that ships with Vensim DSS. It's VBA, but the code should copy/paste to VB without many changes.
There is one function in particular,
Code: Select all
Sub Get_Vensim_Info()
Dim buf As String * 512
result = vensim_command("SPECIAL>LOADMODEL|c:\Program Files\vensim\dll\worldapp.vpm")
vensim_command ("SIMULATE>CHGFILE|changes.cin")
vensim_command ("SIMULATE>DATA|data")
For i = 1 To 21
length = vensim_get_info(i, buf, 500)
Worksheets("Sheet1").Cells(21, 5 + i).Value = buf
Next i
End Sub
You might also find the vensim_get_substring handy for getting the values out of the list (details of this are in the help system,
http://www.vensim.com/documentation/ind ... ?26210.htm).
Be careful when passing a string to the Vensim DLL that is only 4 characters long and telling Vensim it can fill in 500 chars (bb = "test", inforesult = vensim_get_info(10, bb, 500)). It's likely to crash as Vensim will be overwriting memory that it shouldn't.
Hope this helps.
Tony.