Forums > MaxMSP

Setting the filetype of the [text] object

June 23, 2011 | 4:18 pm

Hey
I’m currently using the [text] object to save long lists of integers into a file, which can then later be read back into the patcher using the [text] object again. I’m able to save/write files fine, but when I try and load/read the saved file I am unable to select it as the file is written as a document with no file extension.

How do I set it so the written files are of a .txt file type so that the [text] object will read them? I’ve noticed there’s a ‘filetype’ message you can send to the [text] object – I suspect this is what I need to use but don’t quite understand how to use it correctly.

I’m currently just using the ‘read’ and ‘write’ messages with no arguments so that it brings up the file browser in order for the user to compose/select the name of the file.



Jan
June 23, 2011 | 8:35 pm

send a message like: [write filename.txt]


June 24, 2011 | 12:27 pm

But I don’t want to use an argument such as "filename.txt" as I want the user to be able to select the path and name of the file. But I do want ".txt" added to the end. Could this be done using something like [sprintf] in some way?



Jan
June 24, 2011 | 12:39 pm

[message: TEXT] -> [savedialog]-> [prepend write] ->[coll]



Jan
June 24, 2011 | 12:49 pm

I am not sure if savedialog addes the .txt. if not use [sprintf %s.txt] before sending to coll.


June 24, 2011 | 1:42 pm

Yeah the [savedialog] object really helped thanks!

The algorithm that I’ve settled on is [savedialog] -> [sprintf %s.txt] -> [tosymbol] -> [prepend write] -> [text]


Viewing 6 posts - 1 through 6 (of 6 total)