Lasso Soft Inc. > Home


[Math_Random] returns a random number. This tag can be used to return a random number between the required -Min and -Max parameters. If the optional -Hex parameter is specified then the random number will be output in hexadecimal notation.

Note: For integer output the -Max value is never returned. To get a random sequence of numbers from 0 to N set -Max to N+1. For example, to get a random sequences of numbers from 1 to 6 use [Math_Random: -min=1, -max=7].

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

  • Syntax
  • Parameters
[Math_Random: -Min=Minimum, -Max=Maximum]

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

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. Note that -Max is set to 256 in order to provide random integers from 16 to 255.

[Variable: 'Color'=(Math_Random: -Min=16, -Max=256, -Hex) + 
  (Math_Random: -Min=16, -Max=256, -Hex) + 
  (Math_Random: -Min=16, -Max=256, -Hex)]
<table border="1" cellpadding="9" cellspacing="0">
    <td bgcolor="#[Variable: 'Color']">
      [Variable: 'Color']
    <td color="#05D4A1">
      [Variable: 'Color']
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 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