A newer version of Max is available. Click here to access the latest version of this document.

sprintf

Format a message of words and numbers

Description

The sprintf object allows you to use the famous C-language "printf" function inside Max. You can combine symbols, organize lists of numbers, or format messages or menu items. For complete documentation, refer to a standard C library reference manual.

Arguments

Name Type Opt Description
symout (format-string) symbol Obligatory. If the first argument is the word symout, the sprintf object outputs the string it generates as a single symbol. Otherwise the output is a list of symbols and/or numbers. The word symout itself is not included in the output of sprintf.

The arguments form a message to be sent out, in a format resembling the C programming language. The arguments may be words, numbers, or changeable arguments for incoming symbols (%s), ints (%ld), floats (%f), and ints that are to be formatted as ASCII characters (%c). The number of inlets is determined by the number of changeable arguments, with each inlet corresponding to a changeable argument, in order.

Messages

bang In left inlet: Formats the message using the values currently stored.

Any of the above messages in the left inlet will format the message and send it out. If no value has been received for a changeable number argument (%ld or %f), 0 will be substituted for that argument. If no value has been received for a %s or %c argument, that argument will be left blank.
int input [int]
May be received in any inlet that corresponds to a %ld or %c argument. The number will be stored in place of that argument. A %c argument will convert the int to its ASCII character equivalent.
float input [float]
May be received in any inlet that corresponds to a %f argument. The number will be stored in place of that argument.
list input [list]
In left inlet: Each item in the list is treated as if it had been received in a separate inlet, up to the number of inlets.
anything input [list]
Performs the same function as a list.
symbol input [symbol]
May be received in any inlet that corresponds to a %s argument. The number will be stored in place of that argument.

Information for box attributes common to all objects

Output

anything: The message specified by the typed-in argument(s) is formatted and sent out with substitutions made for the changeable arguments.

Examples

Changeable arguments are replaced by values received in the inlets

See Also

Name Description
atoi Convert ASCII characters to integers
combine Format messages by concatenating multiple atoms into a single symbol.
fromsymbol Transform a symbol into individual numbers/messages
itoa Convert integers to ASCII characters
key Report key presses on the computer keyboard
keyup Report key releases on the computer keyboard
message Send any message
regexp Use PERL-style regular expressions to process input
spell Convert input to ASCII codes
tosymbol Convert messages, numbers, or lists to a single symbol