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

X420R8Q4MV FDCMQPMTZD
RF45O15K1E PAARKGCFAM
7DXN3336K0 ZXGIPUSLCJ
86T7NGK1V0 SRNOUKRCIE
LQHJ3OYLET VSODOOHKNB
{'WME3Y','702BM','QFBQF','JAGZ6','BJ3GT'}
Try it yourself: Open LIB_Function_random_string.b4p in B4P_Examples.zip. Decompress before use.

See also

random