RndStream Random Type (sequential from a pattern file)

Action

Declares a random variable of type RndStream. With each access, such a variable contains a string value selected in sequential order from a pattern file. RndStream reads the values of a file sequentially starting at the beginning of the file. If the end of the file is reached, the next call of RndStream starts at the beginning of the file again. The Silk Performer Reset function has the same effect. The values in the pattern file must be separated with semicolons (;). Leading blanks, tabs and new-line characters are ignored.

Trailing blanks, tabs and new-line characters are part of the value.

If the file name includes a directory name, the file is opened in the specified directory. Otherwise, Silk Performer looks for the file in the folder where the test script is located. If Silk Performer does not find the file there, it looks for the file in the Data folder.

If you are going to use remote agents for the load test, you should store your data files in the Data directory or in the directory where the test script is located. Note that in any case you have to add the data files to your load-testing project.

Syntax

RndStream( in sFileName : string,
           in nMaxLen   : number ): string;

Return value

string

Parameter Description
sFileName String constant specifying the path and file name of the pattern file. The pattern file defines the values to be used by the type. If the path is omitted, the file must be in the current directory.
nMaxLen Maximum length of the return string. If a value in the pattern file is longer than the maximum length, it is truncated to the maximum length.

Example

Pattern File: <public user documents>\Silk Performer 20.5\Data\Efname.rnd

dclrand
  rACat      : RndStr("AABBCCDDEEFF0123456789", 3..4);
  rName      : RndStr(10..40);
  rFirstName : RndStream("<Silk Performer installpath>\\Working\\Data\\Efname.rnd", 20);

dclsql
  InsArticle:
    INSERT INTO article (category, name, firstname)
    VALUES (:rACat, :rName, :rFirstName);

The random variable rFirstName is used in a SQL command to generate sequential values for the database field firstname. The generated values are alphanumeric values. The pattern values are stored in the file <public user documents>\Silk Performer 20.5\Data\Efname.rnd containing the values "Tom", "Ron", "Martin", and "Paul".

The pattern files are loaded into memory for each user when a simulator initializes at the beginning of a test. For large pattern files and multi column random values, we recommend using the new, more flexible random file functions FileCSVLoad, FileFixedLoad and FileGetRndRow.

Note: There are a number of pattern files in your Silk Performer Include directory you can use to generate realistic random names, states, zip codes, cities. Look for files with file extension rnd.