Introduction

This task is designed to be called as a subroutine using the Perform Task action. It takes a format string and a comma separated list of arguments and combines them into a single string for display. It takes its name from the c programming language function sprintf().

Use

%par1 is the format string. The format string contains two types of objects: ordinary characters, which are copied to the output string and conversion specifications, each of which causes conversion and output of the next successive argument to the output string.

For the various conversion specifiers options and their meaning, see the Java printf( ) Method Quick Reference in the files link.

%par2 is a comma separated list of arguments. Each argument corresponds, in sequence, to a matching conversion specifier. String arguments must be enclosed within double quotes.
See the examples.

The Return Value Variable will receive the newly formatted string. If there is an error a message will be displayed and the Return Value Variable will not be set.

Common Errors

Too few arguments - The number of arguments should match the number of conversion specifiers. If there are fewer arguments than specifiers, a "Format string does not match" error will occur.

An argument is the wrong type for it's specifier - Passing a float to a digit specifier or vice versa is one example.

This is especially important for Tasker, because any whole number will be sent to the format engine as an integer. To use a whole number with the f conversion-character it is necessary to append, without quotes, ".0" to the value. See the examples.

Bug fix 8-4-2016: Spaces in the argument string were not handled correctly.