PrintToString does not write to it's first argument. The first argument is the format. The documentation is incorrect. It *used* to be like that but I changed it and forgot to fix teh documentation.
If you use it like this:
string $foo;
int $i;
$i = 10;
$foo = PrintToString("$i = %d", $i);
then $foo will have the value "$i = 10" afterwards.
Here's a sample full shader:
---------------------------------
/* print_to_string.txt */
file $console;
string $str, $str2;
int $ii;
$console.open("$console", "w");
$console.print("I'm writing to the console!\n");
$console.print("The square root of 2 is %12.8f\n", sqrt(2.0));
$str = PrintToString("this is a string");
$console.print("The value of the string is \"%s\".\n", $str);
$str2 = PrintToString("this is a float %6.3f, an int %d, and a string '%s'", 1.2
34, 777, $str);
$console.print("The value of the string is \"%s\".\n", $str2);
$console.close();
---------------------------------
Sorry about the confusion!!!