Format and store a string.
Format and store a string.This function resembles print(), but stores its results in a string instead of printing them. Its workings are not identical! There are subtle but important differences in semantics. Unlike print(), sprint():
- Does not offer page breaks.
- Does not interpret, expand or translate ANSI directives.
- Does not interpret or act on formatting directives.
- Does not consult or alter the output flags.
- Generally alters no state.
Like print(), print() does expand substitution variables.
This function is useful for delayed evaluation of user prompts. Strings created with sprint() can be stored and later shown to the user with print(), which will take care of page breaks, ANSI and formatting directives. Substitution variables will be expanded at the time sprint() was called.
Alternatively, you can prepare a message using msg_getu() and sprint(). Then invoke usr_injoth() to send the string to another user. The string will be formatted locally for that user's terminal and preferences. Substitution variables will reflect the state of affairs of the user calling sprint().