Lasso Soft Inc. > Home

[Math_Random]

[Math_Random] returns a random number. This tag can be used to return a random number between the required -Lower and -Upper parameters inclusive.

If both -Lower and -Upper are integer values then a random integer between them will be returned. The integer can be the -Lower value, -Upper value, or any value in between. If the optional -Hex parameter is specified then the random number will be output in hexadecimal notation.

If either -Lower or -Upper is a decimal value then a decimal value between them will be returned. The precision of the returned decimal value is automatically set to the maximum precision of the -Lower and -Upper parameters, but the value is not rounded.

Note: When returning integer values [Math_Random] can return at most 32-bit values (between approximately +/- 2,000,000,000).

  • Syntax
  • Parameters
[Math_Random: -Lower=Minimum, -Upper=Maximum]

[Math_Random: -Lower=Minimum, -Upper=Maximum, -Hex]
Optional Parameters
-Lower The minimum random number to return.
-Upper The maximum random number to return.
-Hex If specified the random number will be returned in hexadecimal format.
Examples

To generate a random HTML color:

Use the [Math_Random] tag to generate three random hexadecimal numbers between 16 and 255. The following code creates a table cell with a random color.

[Variable: 'Color'=(Math_Random: -Lower=16, -Upper=255, -Hex) + 
  (Math_Random: -Lower =16, -Upper=255, -Hex) + 
  (Math_Random: -Lower =16, -Upper=255, -Hex)]
<table border="1" cellpadding="9" cellspacing="0">
  <tr>
    <td bgcolor="#[Variable: 'Color']">
      [Variable: 'Color']
    </td>
  </tr>
</table>
Result:
<table>
  <tr>
    <td color="#05D4A1">
      [Variable: 'Color']
    </td>
  </tr>
</table>
Tag Link [Math_Random] Category Math
Type Substitution Data Source Any
Support Preferred Version 5.0
Output Type Decimal, Integer, or String Security None
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft