Notifications
Clear all

[Closed] Get the result/value of format

How do I get the result of from the format function? This seems more simpler and easier to understand than concatenating strings.

e.g.


obj = $
testString = "My name is " + obj.name + "and I'm a " + (classof obj) + ". The end"
testFormat = format "My name is % and I'm a %. The end" obj.name (classof obj)

4 Replies

format and print function are methods from WindowStream class, which means they need a stream output to pipe their result.

The output stream by default is obviously the MaxScript Listener Window, but you can specify another one using “to:” parameter.

testFormat = stringstream ""
format "My name is % and I'm a %. The end" obj.name (classof obj) to:testFormat

print <value> to:<filestream>

format <fmt_string> { <value> } to:<filestream>

check out mxs reference

never read this stringstream and the mxs documentation doesn’t connected with it…
thanks…

1 Reply
(@mickaelb)
Joined: 10 months ago

Posts: 0