DESOLATION

Help manual · String Efuns

Sprintf

sprintf - formatted output conversion

string sprintf( string format, ... );

An implementation of sprintf() for LPC, with quite a few extensions Originally implemented by Lynscar (Sean A Reith).

This version supports the following as modifiers:

Note: sprintf() defaults to right justification, which is unnatural in the context of a mainly string based language but has been retained for “compatability”.

meaningful with strings, all other types ignore this. Columns are auto-magically word wrapped.

table within the field size. only meaningful with strings.

corresponding arg as the field size. If n is prepended with a zero, then the field is padded zeros, otherwise it is padded with spaces (or specified pad string; see below).

precision is greater than field size, then field size = precision), tables use precision to specify the number of columns (if precision not specified then tables calculate a best fit), all other types ignore this.

by a zero then the field is padded with zeros instead of spaces.

is applied to each element of the array.

field size (defaults to space) (if both a zero (in front of field size) and a pad string are specified, the one specified second overrules). NOTE: to include “’” in the pad string, you must use “\” (as the backslash has to be escaped past the interpreter), similarly, to include “\ requires “\\”.

The following are the possible type specifiers.

inserted, and all modifiers are ignored.

See also:

sscanf

Tim Hollebeek Beek@ZorkMUD, Lima Bean, IdeaExchange, and elsewhere

Category:String Efuns