Returns a random string.
sString = RandStr (sPicture)
Variable | Description |
---|---|
sString | A random string derived from sPicture. STRING. |
sPicture | A picture clause, which is a string made up of characters with special meaning to RandStr. STRING (maximum of 255 characters). |
RandStr returns a random string with the format you specify in sPicture. Specify the type of random character you want in each position of the output string with one of the following format characters:
A, which returns any alphabetic character in the ASCII character set
X, which returns any alphanumeric character
P, which returns any printable ASCII character
9, which returns any digit (0 to 9)
By default, each format character in sPicture generates a single random character in sString. You can include a length specifier (n) after a format character to specify how many random characters to generate.
The pattern is limited to 4096 characters, including generated characters. If the resulting pattern is longer than 4096 characters, the rest of the characters are ignored, and the resulting string contains: max length 4096
Characters other than the above are not interpreted, and are copied verbatim to the returned string, as in the examples below.
For more information about how random character generation works, see RandSeed Function.
RandSeed (10) Print (RandStr ("A")) // prints n (one random letter) Print (RandStr ("AA")) // prints pB (two random letters) Print (RandStr ("X9")) // prints l3 (one random alphanumeric, one digit) Print (RandStr ("AC")) // prints kC (one random letter, C returned verbatim) Print (RandStr ("Hi there")) // prints Hi there (all returned verbatim) Print (RandStr ("A(5)")) // prints HNuVM (five random letters) Print (RandStr ("AA(5)")) // prints yYsfsw (one letter followed by five letters) Print (RandStr ("A(3)9(5)")) // prints Cjv63947 (three letters, five digits) Print (RandStr ("C(10)")) // prints C(10) (all returned verbatim)