---
url: >-
  /statelake/scripting-reference/functions-and-procedures/string-functions/randomfrom.md
---

# RandomFrom

The function **RandomFrom** returns a randomly selected element from the array **AValues**.

**Declaration**: Function RandomFrom( const AValues : array of string) : string;

This example is a loop that selects random entries.

```pascal
procedure ScriptEvent (var Value : variant);
var
  aStr : string;
  aCount : integer;
begin
  LogInfo('');
  aCount := 1;
 while aCount < 20 do
 begin
    aStr := RandomFrom(['Bob','Ethel','Mary','Florence','Alice','Nigel','Walter','Ermintrude','Horatio','Virginia','Grover'])
    LogInfo(aStr);
    aCount := aCount + 1;
 end;
  LogInfo('');
end;
```
