Format Text String

FmtText

The FmtText procedure is a utility to format text within your program.

The FmtText procedure can create a string of text using substitution variables to format the text. Up to 32 optional substitution variable may be specified and inserted in the the message text at runtime.

szFormattedText    FmtText(
  szMsgPattern         32740A   Const Varying
  szSubstitutionValue1      *   Value OPTIONS(*STRING : *NOPASS)
  szSubstitutionvaluen...   *   Value OPTIONS(*STRING : *NOPASS)
  ... up to 16 substitution values may be specified
)

See also: WrtTrace

Parameters

szMsgPattern
[input VChar(*) value]  A variable or literal that contains the pattern with substitution values. The value(s) from the subsequent parameters are inserted, in order, into this value. The symbolic token used for substitution values is %s.
szSubstitutionValuen...
Zero or one or more character string parameters that are inserted into the szMsgPattern parameter where ever a %s literal is detected (see example). Up to 32 substitution values may be specified. Each value must be character format. For date, time or timestamp values, convert them to character by enclosing them in the %CHAR  builtin-function. For numeric values, convert them to character using %CHAR, %EDITC or %EDITW built-in functions.

Return Value

The return value is a character value containing the formatted text with all substitutions performed.

Remarks

.....C*Rn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++++++++++
     C                   eval       ErrMsg = FmtText('Customer %s is not found.':
     C                                   %char(CustNo) )

In this example the numeric values CUSTNO ise converted to character using %CHAR and inserted into the first parameter in place of the %s substitution symbol.

If CUSTNO = 3741 the field ERRMSG would contain the following:

Customer 3741 is not found.