RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Math.RandomFrom Function

Returns a randomly selected element from an array.

Pascal
function RandomFrom(const AValues: array of Integer): Integer; overload;
function RandomFrom(const AValues: array of Int64): Int64; overload;
function RandomFrom(const AValues: array of Double): Double; overload;
C++
int RandomFrom(const array of Integer AValues);
Int64 RandomFrom(const array of Int64 AValues);
Double RandomFrom(const array of Double AValues);

RandomFrom returns a randomly selected element from the array passed as the AValues argument. In C++, AValues_Size is the index of the last array element (one less than the number of elements.) 

To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to RandomFrom. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!