Technical data
2 
Working with the Target Language
2-46
Variable Scoping Within Functions
Within a function, the left-hand member of any %assign statement defaults to 
create a new entry in the function’s block within the scope chain, and does not 
affect any of the other entries. That is, it is local to the function. For example,
%function foo (x,y)
%assign local = 3
%endfunction
adds local = 3 to the foo( ) block in the scope list giving:
Figure 2-7: Scoping Rules Within Functions Containing Local Variables
Global Pool
%assign a = … 
%assign b = …
…
Top-Level RTW Pool
CompiledModel {
…
}
%with CompiledModel.
System[Sysidx] 
2
3
4
1
%function function(…)
foo (x,y) 
local = 3










