Configure the Random Number Generator Function

This task describes how to configure the random number generator function.

Prerequisite: Select the function

  1. In the Data Model Editor, expand a rule.
  2. Click inside the function field (fx) of a response column and select Random number generator. If the function row is not displayed, from the View Options menu, select Functions.

    Note: Dynamic data functions are available for lowest level headers only. Complex headers that include lower level headers under them are displayed in italic text (header). To display lower level headers, double-click the column header.

Back to top

Configure the function

In each cell under this function, enter a value in the following format:

Minimum_number;Maximum_number;FormatString

where:

  • Minimum_number is the lowest possible number to be used in the output of the random number generator.
  • Maximum_number is the highest possible number to be used in the output of the random number generator.
  • FormatString defines the format of the output of the random number generator.

The format string includes:

  • a regular text string
  • (optional) one or more special sequences to define the format of the numerical output of the generator

To determine the output of the number generator, Service Virtualization goes through the format string and constructs an output string using specific rules, explained below.

Back to top

Format special sequences

Special sequences enable you define the format of the numerical output of the function.

You construct special sequences as follows:

  • Each special sequence must start and end with the '#' character.
  • Each special sequence must contain one or more ‘D’ characters. These characters act like a digit wildcard for a number that will be generated by this generator function. The number will always occupy exactly the number of specified digits. If the number does not occupy all digits, zeros are added before it so that it does.

    Example:

    - If the special sequence is #DDDD#

    - and the number generated by the function is 568

    - the output is 0568.

  • A special sequence may also contain 'd' characters. These characters act as placeholders. If the output of the generator function requires this space, then it will hold a number. If the generated number does not occupy all digits, then the extra spaces are left empty, and not populated with zeros. 'd' characters may only be placed before 'D' characters.

    Example:  

    - If the special sequence is #ddDDD#

    - and the number generated by the function is 9857

    - the output is 9857.

    For the number 125:

    - the sequence #DDDDD# outputs 00125

    - the sequence #ddDDD# outputs 125

    - and the sequence ##dDDDD outputs 0125.

  • You can construct a format string with multiple special sequences.

    Example: You can enter a special sequence to resemble a credit card number format:

    - if the special sequence is #DDDD#-#DDDD#-#DDDD#-#DDDD#

    - and the number generated is 1234567812345678

    - the output is 1234-5678-1234-5678

Service Virtualization defines the output of the generator according to the following additional guidelines:

  • If the number is greater than the maximal number that can be stored within the digits, it is truncated so that it fits within (e.g. if the number was 3456 and the special sequence was #DDD#, the output will be 456).
  • If the number is negative, it is truncated the same way as above. Then an additional offset is applied. The value of this offset is based on the number of digits and is selected so that -1 becomes the biggest number that fits within these digits. For example, if the special sequence was #DDDDD#, -1 becomes 99999. If it was #DD#, -67813 becomes -13 which then becomes 87.
  • For each empty special sequence (when there are two ‘#’ characters next to each other), a single ‘#’ character is inserted into the output string.
  • The numerical output of the generator will be a number that has exactly as many digits as there are 'D' characters in all of the special sequences in the field combined.
  • Any characters that are not part of a special sequence are copied to the output string.

Back to top

Examples

Example: To generate a random number between 0 and 9999999, to be appended to the number 201, type the following format into each cell under the random number generator function:

0;9999999;201#DDDDDDD#

where:

0 is the minimum number

9999999 is the maximum number

201 is a text string,

and #DDDDDDD# is a special sequence, indicating that the generated number can be up to 7-digits in length

Result: The output is any number between 2010000000 and 2019999999.

Instead, you could format the cell as follows:

0;9999999;201#dddDDDD#

Result: The output is any number between 2010000 and 2019999999.

Back to top

See also: