Hi , i have a folder with my pd patch and another folder that stores txt files ( my data).
How can i read my txt files from that folder using relative path? I need to be able to change the location of my folder and not having the necessity of rewriting the path.
any idea?
R.
On 28/08/2013 02:17, Ronni Montoya wrote:
Hi , i have a folder with my pd patch and another folder that stores txt files ( my data).
How can i read my txt files from that folder using relative path? I need to be able to change the location of my folder and not having the necessity of rewriting the path.
any idea?
Assuming you're using [textfile], something like this should work
[read ../path_to_file/file.txt( | [textfile]
Lorenzo.
hi, [read ../data/colors.txt ( doesnt work here on macosx.
I ve tried in the following way and it worked.
[ read data/colors.txt (
I was wondering if the way im doing this will allow the patch to work only on macosx?
If yes, is there is a way of solving this?
2013/8/28, Lorenzo Sutton lorenzofsutton@gmail.com:
On 28/08/2013 02:17, Ronni Montoya wrote:
Hi , i have a folder with my pd patch and another folder that stores txt files ( my data).
How can i read my txt files from that folder using relative path? I need to be able to change the location of my folder and not having the necessity of rewriting the path.
any idea?
Assuming you're using [textfile], something like this should work
[read ../path_to_file/file.txt( | [textfile]
Lorenzo.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Wed, Aug 28, 2013 at 07:31:54PM -0700, Ronni Montoya wrote:
hi, [read ../data/colors.txt ( doesnt work here on macosx.
I ve tried in the following way and it worked.
[ read data/colors.txt (
I was wondering if the way im doing this will allow the patch to work only on macosx?
If yes, is there is a way of solving this?
Pd's way of referencing files with relative paths can be a bit peculiar, because depending on where your patches and abstractions are and what is the Pd search path you have configured, Pd might use different places to start its file search.
Unless you can use absolute paths, in my experience a good way to help Pd looking for files is to use a [declare]-object in your toplevel patch to add the directory, where the toplevel patch file is to the search path.
So in your toplevel file, lets assume it's called "main.pd", use declare like this:
[declare -path .]
The final dot (".") is the current directory, where main.pd is, which would be "workdir" in a tree like this:
After that can use all these to open files:
[read data1/colors.txt ( [read ../data2/colors.txt (
and it should even work, if yout have a [mylib/filereader] abstraction in main.pd, that has your [textfile] inside.
All this is not dependent on the operating system, so it will work on OS-X, Linux, iOS, Android, etc.
Frank Barknecht _ ______footils.org__