Up

sprintf

sprintf has a same objective than the C-standard function : formatted output conversion. See the note to the protoype.

Prototype :

fun [S u0] S

Return : S a new string or nil if error

Error :

See also :

printf

strcat

strcatn

Examples :

typeof string = S;;
...
set string = sprintf "%s is %s %d" ["Christmas Day" "December" 25]; 
_fooS string;
// >>>>> Christmas Day is December 25

typeof mylist = [[S S I] r1];; /* a string, an hex, an integer */
...
fun readMyList (list)=
	if list == nil then
		0
	else
	(
		// 'hd list' is a tuple [S S I] ...
		_fooS sprintf "1th : %s, 2nd : %x, 3rd : %i" hd list;
		readMyList tl list
	);;
	
fun main ()=
	_showconsole;
	...
	readMyList myList;
	...

An example with an item at nil :

typeof string = S;;
...
set string = sprintf "This %ith value is %i" [4 nil]; 
_fooS string;
// >>>>> This 4th is %i

Note