For large models it can be slow to run a game because of the time it takes to store data on each play of the game. This can be speeded up quite a bit by having Visual Basic control the progress of the game. The button labeled "Continue a game without intermediate storage of results" does this.
Dim timeval As Single
result = vensim_command("GAME>GAMEINTERVAL|250")
If result = 0 Then Exit Sub
' now do the work
result = vensim_start_simulation(1, 2, 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 |
| stime$ = 0.05 * (1 - (timeval - 1900#) / 200#) |
| comstr$ = "SIMULATE>SETVAL|capital investment rate normal=" + stime$ |
| result = vensim_command(comstr$) |
| If result <> 1 Then Exit Do |
Loop
Label2.Caption = "Storing Results"
Label2.Refresh
result = vensim_finish_simulation()
Label2.Caption = " "
In this case we are computing the value to set a gaming variable to. In general you will want to let the user set values. In this framework if you want to back up in a game, it would be necessary to call vensim_finish_simulation() and then execute the GAME>BACKUP command.