strembed(X;N;P;Y;D)

Returns a given string embedded within a template that consists of a string value repeated a particular number of times.

Syntax

strembed(X;N;P;Y;D)
bstrembed(X;N;P;Y;D)

Input

Argument Type Description
X text The string value that will be repeated to create the template in which Y is embedded

A scalar value or the name of a column

N integer The number of times X is repeated to create the template.

A scalar value or the name of a column

P integer An index corresponding to the position in the template where Y is to be embedded

The index P is 1-based (i.e., the first character has position 1).

  • If P is positive, then the beginning of Y is placed at the P'th character of the template.
  • If P is negative, the end of Y is placed at the P'th character from the end of the template.

A scalar value or the name of a column

Y text The string to be embedded in the template

A scalar value or the name of a column

D integer D specifies how Y is handled if it goes over the end of the template
  • If D=1, Y is truncated as necessary.
  • If D=0, the unmodified template is returned.
  • If D=-1, the result is N/A.

A scalar value or the name of a column

Return Value

Returns the text value corresponding to a "template" consisting of the string X repeated N times; the string Y is embedded in the template at the position denoted by P.

If X or N is N/A, then the result is N/A.

Sample Usage

value times position string overflow strembed(value;times;position;string;overflow)
'*' 9 3 'Apple' 0 '**Apple**'
'0' 5 -1 '172' 0 '00172'
'0' 5 -1 '172819' 0 '00000'
'0' 5 -1 '172819' 1 '72819'
'0' 5 -1 '172819' -1 ''
'0' 3 -1 '172819' 1 '819'
'0' 3 -1 '172819' 0 '000'
'0' 3 -1 '172819' -1 ''

Additional Information

  • strembed is Unicode (UTF-8) compliant and will work with Unicode or plain ASCII text fields.
  • If passed a string argument that is not legal Unicode, it will by default signal an error (configurable as a user preference).
  • A corresponding function bstrembed can be used with non-Unicode strings (e.g., binary or legacy encodings).