random string, random letters

Prev Next

Function Names

random string, random letters

Description

This function creates a string containing random upper-case characters from A..Z and digits 0..9. The function random letters generates strings with upper-case characters from A..Z only.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-2

Parameters

No.TypeDescription
1
input
numeral character count

Specifies the number of random characters in the string.

Opt. 2
input
numeral number of output strings to generate

If this 2nd function parameter is specified, then the generated strings are returned in a set. An empty set is specified if the value is 0 or negative.

Return value

TypeDescription
string
set
Generated random string(s)

In case the 2nd function parameter with a string count is specified, then a set containing the strings will be returned.

Exceptions

Invalid character code (outside 0 - 1114111 range)

Examples

       for (i[] = 1, i[] <= 5, i[]++)
       {
               echo( random string( 10 ), " ", random letters( 10 ) );
       }
       echo( random string( 5, 5 ) ); // 5 strings returned in a set

Output

K3UE9KBGE4 ZEBISLGHXF
BH4JS0S3XQ ODOVKOETQL
5N5VV30OTU YREVQTWTEB
7L4QRE1CUL YIHGOZDBLD
3WBOQ7U7AP NWMUQZAEKW
{'JQJ6R','EMBM9','W8KTZ','CZFTE','4U4DA'}
Try it yourself: Open LIB_Function_random_string.b4p in B4P_Examples.zip. Decompress before use.

See also

random