String (%STR) Macro

Applies to TestComplete 14.91, last modified on July 20, 2021

Description

The String macro is used to insert arbitrary text data into the string generated with the Custom String generator.

The macro is an analogue of the String data generator.

Syntax

The macro has the following syntax:

%STR(MinLength, MaxLength, L, D, S, P)

Parameters

MinLength and MaxLength

Optional parameters. Specify the length of the shortest and the longest generated string respectively. The value of the MinLength parameter must be less than or equal to the value of the MaxLength parameter.

Important notes:

  • If only one of the numeric parameters is specified, TestComplete uses the same value for another numeric parameter. You can use this approach to generate strings with a constant length.

  • If none of the MinLength and MaxLength parameters is specified, TestComplete uses the following default values for them: MinLength = 1 and MaxLength = 8.

L, D, S, P

Optional parameters. Specify which characters will be used to generate the resulting string:

  • L (or Letters) - The generated string will contain letters.

  • D (or Digits) - The generated string will contain digits.

  • S (or Spaces) - The generated string will contain spaces.

  • P (or Punctuation marks) - The generated string will contain punctuation marks.

If none of the parameters described above is specified, TestComplete uses any characters (letters, digits, spaces and punctuation marks) to generate custom strings. If at least one parameter is specified, TestComplete will generate strings that contain the corresponding characters only.

*xN

Optional parameter. Specifies the number of possible repetitions of each value in series of generated strings. N is a positive number that specifies the number of repetitions: 1, 2, 3, and so on. The default parameter value is *x1 (no repetitions).

Examples

The following examples demonstrate how to use the String macro:

  • %STR(1, 8, L, Digits, S, P)

    Generates strings 1 - 8 characters long that contain letters, digits, spaces and punctuation marks.

  • %STR(4, Letters, 10, P, *x3)

    Generates strings 4 - 10 characters long that contain letters and punctuation marks only. Each of the generated values will be repeated 3 times.

  • %STR(8, 3, P, L, Spaces) <— Incorrect

    Generates any string, since the value of the MinLength parameter (in our example, 8) is greater than the value of the MaxLength parameter (in our example, 3). This example will work as expected if you use the following syntax:

    %STR(3, 8, Punctuation marks, L, S) <— Correct

    Generates strings 3 - 8 characters long that contain letters, spaces and punctuation marks only.

  • %STR(7, S, D)

    Generates strings 7 characters long that contain spaces and digits only.

  • %STR(Letters)

    Generates strings 1 - 8 characters long that contain letters only. Here, the default parameter values (MinLength = 1 and MaxLength = 8) are used.

Remarks

  • The first number in the macro parameters is treated as the value of the MinLength parameter. The second number in the macro parameters is treated as the value of the MaxLength parameter. So, the first number specified in the macro parameters must be less than or equal to the second number (see the parameters' description above).

    The order of the other parameters does not matter.

  • For more information on adding macros to custom strings, see About Custom String Generator

  • For more information on general rules used for specifying macro parameters, see Custom String Generator Rules.

See Also

Macro Reference
Custom String Generator Rules
Custom String Generator
String Generator
Using Data Generators
Generate Data Dialog

Highlight search results