Setting the filetype of the [text] object

millenliam's icon

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 M's icon

send a message like: [write filename.txt]

millenliam's icon

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 M's icon

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

Jan M's icon

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

millenliam's icon

Yeah the [savedialog] object really helped thanks!

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