3DS Max, MaxScript string formatting problem

coding
max
maxscript

#1

When i try to format a string it’s always put an “OK” the end of it.
And also the variable only keep the “OK”.
Any ideas?


#2

I believe you have to create a stringStream and pass that into the format function. Otherwise, you’re just storing the return value of the format function, which is “OK” (which is lame). So:

myStringStream = stringstream ""
format "%" someVar to:myStringStream

#3

Yes, you always have to format() to something. Generally it is either a StringStream or directly to the Listener REPL.


#4

I use format regularly to print debug information directly to the listener just add a newLine ( \n ) character at the end.

format "Hello %\n" "world"

The OK appears now on a new line. The reason the OK is there because that is the return value of the format function. If you don’t want that, then indeed use format “%” stringStreamValue

-Johan


#5

Thank you all the replies!