Search Top Index
HELP SPRINTF Mark Rubinstein February 1985 sprintf(<string>, [% item1, item2, ..., itemn %]) -> string; OR sprintf(itemn, ..., item2, item1, <string>) -> string; SPRINTF is a relatively cheap and cheerful way of getting formatted strings of the kind printed by PRINTF. Its use is exactly analogous to the use of printf (see HELP * PRINTF) and all the same field specifiers may be used, but instead of printing a string it returns the string as a result. For example: vars x; sprintf('the sum of %p and %p is %p\n', [3 4 7]) -> x; x => ** the sum of 3 and 4 is 7 In order to be consistent with PRINTF it allows the two forms of invocation :- sprintf(string, [arg1 arg2 ... argn]); and sprintf(argn ... arg2, arg1, string); but in order to allow the second form it has to do a certain amount of preprocessing to turn it into a call of the first form. Thus the first form is preferable.