|C/C++||int VEFCC VensimContextAdd(int wantcleanup) ;|
|Java||public static native int ContextAdd(int wantcleanup) ;|
Creates a new context for the server version of the Vensim DLL. Each context is a separate environment that can have its own model and will run in its own state. When a model is open in a context created in this manner Vensim will create a subdirectory to perform all operations.
wantcleanup a flag to indicate that when the context is closed all files associated with the context will be deleted. If this is 0 the files will not be deleted, otherwise they will.
A positive context number to indicate success, 0 to indicate failure. The returned value can be passed as the context argument in calls to the DLL functions.
Each time a model is open a subdirectory will be created in the directory the model is in and all files from simulations will be created in that subdirectory. You can still refer to other files (optimization control and so on) without any additional directory information, Vensim will take care of the location relative to the place where the runs will be stored. If the wantcleanup flag is nonzero then each time a new model is open the files associated with the old model will be deleted, and the directory that was created will be removed.
Contexts are independent and thread safe. That means you can have different threads calling different contexts at the same time.