Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Printing to a text file, enclosing quotes?

Printing to a text file, enclosing quotes?

Anonymous
Not applicable
298 Views
4 Replies
Message 1 of 5

Printing to a text file, enclosing quotes?

Anonymous
Not applicable
Ok, again, the small is stumping me and i know its most likely something simple. In the 3 days developing a complicated exporter/converter for some of our level files its the smallest thing,


f = openFile exportFilePath_ mode:"wt"
x = "information {\n"
x += "key = \"value\";\n"
x += "};\n"
print x to:f


All variables work and are declared , just what i get is output is

"information {
key = "value"
};"


This, as you imagine is not desirable. How do i get rid of the quotes that it adds when writing a string to a file.

print "hello" to:filestream makes the file contain "hello".
i need it to write hello.
0 Likes
299 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
use format instead...

format "%" x to:f
0 Likes
Message 3 of 5

Anonymous
Not applicable
Aha, i thought format was to help print if needed, the docs were a little unclear on the difference (or maybe im just spacing out).

Thanks a lot, ScriptChimp
0 Likes
Message 4 of 5

Anonymous
Not applicable
no problem....

Format is useful for rearranging text, it's also more robust than print when it comes to casting data
as a string.

I gave you a simple one line fix, but you could have done the whole thing in one line...

format "information {\nkey= \"%\"\n}\n" value to:f
0 Likes
Message 5 of 5

Anonymous
Not applicable
Yea, i was using it elsewhere to format strings, i just didnt realise it "prints" them to the stream. It works great now though,

And the above, i only posted a few line example. My string is actually built over hundreds of lines using UserProperties etc 🙂
Thanks again
0 Likes