Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter SevenMath Functions (continued)

Random Function

Overview

The Random function returns a random integer from 0 to 0x7FFF (32,767).

Syntax/Parameters

Syntax

int = Random ( );

Parameters

(none)

 

Return Value

Returns an int as a random value.

Remarks

The random number is generated by an algorithm that returns a sequence of apparently non-related numbers each time it is called. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using the SeedRandom function.

A typical way to generate trivial pseudo-random numbers in a determined range using the Random function is to use the modulo of the returned value by the range span and add the initial value of the range:

v1 = Random() % 100;       // v1 in the range 0 to 99

v2 = Random() % 100 + 1;   // v2 in the range 1 to 100

v3 = Random() % 30 + 1985; // v3 in the range 1985-2014

Notice though that this modulo operation does not generate uniformly distributed random numbers in the span (since in most cases this operation makes lower numbers slightly more likely).

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic