DADiSP Worksheet Functions > Function Categories > Annotation > SFORMAT

 

SFORMAT

Purpose:

Formats a list of strings.

Syntax:

SFORMAT("control", "arg1", "arg2",..., "argN")

"control"

-

Format control string. Conforms to C/C++ language sprintf specifications. Control strings may contain ordinary characters, escape sequences, and format specifications. The ordinary characters are copied to the output string in order of their appearance. Escape sequences are introduced by a backslash (\). Format specifications in the control string are introduced by a percent sign (%), and are matched to the specified arguments in order. If there are more arguments than there are format specifications, the extra arguments are ignored.

"argN"

-

A string value that matches the control string.

For the control string, the Format Specification Fields are specified in the following form:

% [flags] [width] [.precision] type

 

Flags are optional characters that control justification of output and printing of signs, blanks, decimal points, and octal and hexadecimal prefixes. More than one flag can appear in a format specification.

Flag 

Meaning

-

Left justify

 

Width is an optional number that specifies the minimum number of characters output.

 

Precision is an optional number that specifies the maximum number of characters printed.

 

Type is a required to be the character s to indicate string formatting.

Returns:

A string.

Example:

sformat("Comment: %s", getcomment)

 

returns a string like "Comment: IBM"

Remarks:

SFORMAT is a variation of the SPRINTF function that is constrained to strings only. See SPRINTF for generalized formatting.

 

See any standard C/C++ language reference for further information.

See Also:

NFORMAT

SPRINTF

STRCAT