Each (new) macro has its own namespace to enable portability. This means that within a macro component and pipe names can be assigned in any way, regardless of the fact whether the same name has already been assigned in the model or not. So even multiple insertions of the same macros into a model are possible.
Since it can happen that a component with the name "Throttle_1" appears in the main model as well as in a macro 1 and also in a macro 2, when using these names in an EbsScript, it must be clear, which of these objects is meant. This is done with the help of the context.
As soon as a macro is inserted in the model, a new name space is created that bears the name of the macro. In the EbsScript Editor it can be selected in the EbsScript context bar (combo box "Open Context"). The component and pipe names used in the EbsScript will refer to this selected context.
The same applies to additionally inserted passive sheets (parallel to the one default active sheet called <Calculation> by default).
The EbsScript line
Throttle_1.DP12RN:=0;
therefore sets the pressure loss of "Throttle_1" in the main model to 0, if the context is set to "Global" or "(Top Level)" resp. (default setting).
To change the pressure loss of "Throttle_1" in a Macro1 to 0 with this command, a changeover of the context to "Macro1" must be made before compiling.
Alternatively, it is also possible to specify the context by the variable itself:
Macro1::Throttle_1.DP12RN:=0;
sets the pressure loss of "Throttlel_1" in the Macro1 to 0, even if the context is set to "(Top Level)".
Vice versa, a preceding "::" accesses a component or pipe in the Top level context, even when the EbsScript-Editor context is not set to "(Top level)":
::Throttle_1.DP12RN:=0;
Since macros can be used within other macros, a concatenation of the context names is also possible. The expression
Condensing::ExternalCooling::Electro_3.Q
points to the electrical power on the line Electro_3 within a macro "ExternalCooling", which itself is contained in a macro "Condensing".
In EbsScript you can use "..." to jump to the superordinate context, e.g.
::ActContext::..::component.spec.
In particular, this makes it easier to reach the connected components from a macro.
For changing the context (e.g. for jumping to a macro context when compiling) there is the following EbsScript directive:
If you switch the context by using the "Active Context" Combo Box from the profile toolbar a new window will be created showing the objects inside this context.
When you edit an EbsScript of a (new) macro from within the macros properties window (EbsScript to be run before calculation, EbsScript to be run after calculation, EbsScript to take over nominal values) the combo box "Active Context" shows the context of this macro. Here this context can not be changed.
The "Open Context" combo box from the profile toolbar and the "Active context" combo box from the EbsScript editors "EbsScript context" toolbar are independent from each other,
To change the context while an EbsScript is running, you can use the EbsScript functions setContext, getContext, resetContext, setGlobalContext (see EbsScript Functions-->Calculating Functions).