Supplementing the Model with Handwritten Code : Supplementing the Model with a Procedure : Using Globals

Using Globals

If you use the same parameters for multiple activities, you may want to define them as globals. If so, use the Implementation menu (shown below) to select Globals Usage.

 

For example, the ADD_JOB_TO_RQ procedure uses the globals shown in the following dialog box.

Note: Globals are elements that are external to the subroutine, but are not listed as parameters. The reading or writing of global data is called a side effect.
.

Writing more than once to a global element is considered racing. However, this racing differs from general racing where you have no way of determining which value will be assigned. In this case, the final value will be the resulting value of the global element. Therefore, it is your responsibility to ensure that the subroutine writes to global elements only a single time during its execution.

Note: It is strongly recommended that you do not write global data in a function called in a trigger expression. Side effects written as part of a trigger will behave differently between simulation and code.