Random - method of the Pm object
Description:
Returns a random number in defined range.
Syntax:
Double Random(Double nLow, Double nHigh)
Parameters:
nLow | (Double) bottom range limit |
nHigh | (Double) upper range limit |
---|
Example1:
Computation of a random number in the range from 0 to 100 rounded to a integer
JavaScriptVBScriptSelect and copy to clipboard
var nVar = Pm.Round(Pm.Random(0, 100), 1);
Dim nVar
nVar = Pm.Round(Pm.Random(0, 100), 1)
Example2:
Emulation of "Temperature" value in defined range.
JavaScriptVBScriptSelect and copy to clipboard
var oVar = pMe.Pm("/Data/#vars/Temperature");
var nMin = 20;
var nMax = 100;
oVar.Value = oVar.Value + 0.1 * Pm.Random(nMin - oVar.Value, nMax - oVar.Value);
Dim oVar, nMin, nMax
Set oVar = pMe.Pm("/Data/#vars/Temperature")
nMin = 20
nMax = 100
oVar.Value = oVar.Value + 0.1 * Pm.Random(nMin - oVar.Value, nMax - oVar.Value)