Combination View Flat View Tree View
Threads [ Previous | Next ]
RE: Loading and discarding models with AdoScript
toggle
Hi,

I found two code snippets in the developer's wiki that call LOAD_MODEL in AdoScript without a corresponding call to DISCARD_MODEL:

Here and here.

However, the ADOxx Help explicitly says to call DISCARD_MODEL. In German:
ACHTUNG: Jedes Model, das über den "Core"-MessagePort erzeugt oder geladen wird, muß mit DISCARD_MODEL wieder freigegeben werden.


Which one is right: Help or Wiki? What are the consequences of loading models without discarding them?

Thanks,

Stefan
Flag Flag
RE: Loading and discarding models with AdoScript
8/29/11 6:31 PM as a reply to Stefan Hofer.
Hi Stefan,

the correct way is to discard the model after loading - in case it has not been loaded before. The same best practice applies to the opening of models. This is to ensure that potential other users or scripts running with these user rights can again access the model. If you are not working in a multi-user environment there might not be any immediate effects but I would still recommend to follow this procedure:

1. Check if model is loaded/opened
2. Store state of loading/opening
3. Load/Open model if not opened/loaded
4. -- Perform operations --
5. Save modified model if necessary
5. Check if model was loaded/opened before and discard/close model accordingly to restore previous state

Hope this helps.

Hans-Georg
Flag Flag
RE: Loading and discarding models with AdoScript
9/1/11 10:45 AM as a reply to Hans-Georg Fill.
Hi,

thanks for clearing that up. In addition to multi-user concerns, loading models without discarding them has serious issues even for a single user: Imagine you opened a model and one of its elements has an INTERREF attribute that links it to an element of some other model. That INTERREF attribute presents itself as a kind of hyperlink and if you click on it, the referenced model is opened. However, if the referenced model is still closed and then loaded by AdoScript you cannot open it anymore by clicking on INTERREF-hyperlinks. Only if your AdoScript code discards the referenced model it can be opened by clicking on an INTERREF-hyperlink.

On a side note: Loaded models are in state "loaded". Opened models are in state "loaded" and "opened". That's good to know when loading/opening models with AdoScript.


Stefan
Flag Flag