Run Step by Step from DDE

Use this forum to post Vensim related questions.
Post Reply
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Run Step by Step from DDE

Post by Camila »

Hi,

I'm trying to control Vensim from Excel with a DDE in VB, but I can't find how to run one step of the simulation, like in games. Does anyone knows how to do that?

Thanks!!
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Use MENU>GAME and GAME>GAMEON to move forward bit by bit.
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Post by Camila »

Thank you Bob,

I have tried that, and the MENU>GAME works fine, but the GAME>GAMEON doesn't seem to do anything.

I have this instructions in VB:

Sub Game()
Application.DDEExecute DDE_channel, "[MENU>GAME|o]"
End Sub

Sub Avanzar()
Application.DDEExecute DDE_channel, "[GAME>GAMEON]"
End Sub

Camila.
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Post by Camila »

Well, I have solved the problem of running step by step with the vensim_start_simulation and vensim_continue_simulation functions, but I still can't get the value of a variable without running the complete simulation, it seems that vensim doesn't save that information before Final Time.
Is there any way of getting values from vensim variables in each step?

Thanks!

Camila.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

If you are using vensim_continue_simulation you can use vensim_get_val to get the value at the current time - see the manual entry for vensim_start_simulation for details.
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Post by Camila »

The only value I can get in each step is Time. I have tried using vensim_get_val and Application.DDERequest for other variables, the first one returns 0 unless I have run the complete simulation, and the other, using the time value I get with vensim_get_val, does not return any value.
Both of them work well when I have run the complete simulation, but I need to get the data before that.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

If you can get time, but not any other variable, that suggests to me that you may be simulating a different model from the one you think is being simulated. Try to get SAVEPER and see what happens. If it returns a value you may be simulating an empty model.
Post Reply