Math Random and SetRandomSeed Example
In this example, Math.SetRandomSeed is used to make sure the result is the same for every rendering. Then a mathimatical addition is assembled using the For macro together with Math.random. Finally, the expression is evaluated using String.Eval.
Smartsite SXML | Copy Code |
---|---|
{math.setrandomseed(12345)} <se:for from="1" to="10" whitespace="remove" save="rnddata"> {sys.iif(this.index() GT this.getparameter(from), ' + ', rem='skip for first enty')} {math.random(1,100)} </se:for> Calculate: {buffer.get(rnddata)} Result: {string.eval($rnddata)} |
Example Result | Copy Code |
---|---|
Calculate: 7 + 8 + 78 + 52 + 80 + 83 + 17 + 74 + 27 + 51 Result: 477 |