repeat

Date:

02-06-2023

NAME

REPEAT - Concatenates several copies of a string

SYNOPSIS

REPEAT ([STRING=]string, [NCOPIES=]ncopies)

STANDARDS

Fortran

DESCRIPTION

The REPEAT intrinsic function concatenates several copies of a string. It returns the specified number of concatenated copies of the input string as the result. If the number of copies is zero, the result is a string of zero length.

REPEAT accepts the following arguments:

string

Must be a scalar and of type character.

ncopies

Must be either 0 or a positive integer. Must also be a scalar.

REPEAT is a transformational function. The name of this intrinsic cannot be passed as an argument.

RETURN VALUES

The result is a scalar entity of type character with a length of ncopies times the length of string. The value of the result is the concatenation of ncopies of string.

If ncopies is zero, the result is a string of zero length.

EXAMPLES

In the following program, a literal with a trailing blank is repeated.

CHARACTER (LEN=14) :: CHVAR
CHVAR = REPEAT('STRING ',2)
PRINT '(3A)', '>', CHVAR, '<'

The output of the program is:

>STRING STRING <