RndFile Random Type (strings from a pattern file)


Declares a random variable of type RndFile. With each access, such a variable contains a random string value that is generated following a uniform distribution. The strings are selected randomly from a pattern file. The values in the pattern file must be separated with semicolons (;). Leading blanks, tabs and newline characters are ignored. Trailing blanks, tabs or new line characters are part of the value. Each position in the pattern file has the same probability of being chosen. The position in the pattern file is generated randomly. The value located at the randomly generated position is chosen to be the next value of the random type.

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 load-test script is located. Note that in any case you have to add the data files to your project.


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

Return value

random positions

First random value: Martin

Second random value: Tom

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 random type. If the path is omitted, the file must be in the current directory.
nMaxLen Maximum length of the random string. If a value in the pattern file is longer than the maximum length, the value is truncated to the maximum length.


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

First random value: Martin

Second random value: Tom

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

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

The random variable rFirstName is used in a SQL command to generate random 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 21.0\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 load 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 these to generate realistic random names, states, zip codes and cities. Look for files with file extension rnd.