Dim timeval As Single
result = vensim_command("SIMULATE>RUNNAME|bobblah")
If result = 0 Then Exit Sub
num$ = Text1.Text
comstr$ = "SIMULATE>SETVAL|POPULATION INITIAL = " + num$
result = vensim_command(comstr$)
If result = 0 Then Exit Sub
' now do the work
result = vensim_start_simulation(1, 0, 1)
If result = 0 Then Exit Sub
Do |
result = vensim_get_val("Time", timeval) |
If result = 1 Then |
stime$ = timeval |
Label2.Caption = "Time = " + stime$ |
Label2.Refresh |
End If |
result = vensim_continue_simulation(20) |
If result <> 1 Then Exit Do |
Loop
Label2.Caption = "Storing Results"
Label2.Refresh
result = vensim_finish_simulation()
Label2.Caption = " "
End Sub
Controlling simulation is a little more complicated then just launching a simulation, but it provides an opportunity for the user to see the progress of the simulation. Here the progress is displayed with a simple text showing the value for time. The value with which vensim_continue_simulation is called (20) determines the number of TIME STEPS that will be run. A bigger number takes longer, but there is some overhead in calling the functions so using 1 is probably not a good idea.