Real
Local Variable Declaration Statement
The Real statement creates a local Variable of type Real. A local Variable is similar to a normal Variable, but it is only available within the Logic where it is defined. Use the Real statement to define test Variables for Logic loops or other Variables that do not need to be global.
Syntax
Real <name1>{= <expression1>, <name2>= <expression2>...}
Syntax Examples
Real Var1
Real Counter = 0
Real Var1 = Clock(sec), Random_Num = Rand(10)
Parameters
<names>
An identifier for the first local variable. This identifier must be a valid name.
<expressions>
The variable is initially assigned this value. This expression is evaluated every time the Real statement is encountered.
Parameter Examples
Suppose a model simulates a single 12 hour day where more Painter Resources are available in the early morning and in the late evening. There is only one Location in your model, Painting, that uses Painter Resources. Subsequently, you decide a local Variable is more effective than a global Variable to track their availability. To simulate the Painting Location using more Painter Resources during the time when more are available, define the statements...
Real vCurrentTime = Clock(hr)
{
If vCurrentTime > 4 and vCurrentTime < 8
Then Use 2 Painter For 10 min
Else
Use 4 Painter For 10 min
}
...in the Painting Location Logic. The Real statement creates a local Variable that is equal to the elapsed amount of time in the simulation in hours. Note that the Real statement is preferable to the Int statement in this case because the Clock function returns values of the real type. The If Then...Else statement uses the vCurrentTime Variable to determine how many Painter Resources to use. If the simulation is still in the early morning (before four hours have passed) or late in the evening (after eight hours have passed), four Painter Resources are used. If the simulation is still in between these two time frames, only two Painter Resources are used.
For more information on the statements used in this example, see If Then Statements, Else, Use, Clock, and Int.
Remarks
A local variable is created for each entity that encounters a Real statement.
Local variables are not directly available to subroutines, which have their own local variables. However, a local variable may be passed to a subroutine as a parameter. Local variables are available to macros.
Variables declared with Real are valid in any expression within the logic where a real number is valid.