[PD] Reading txt file inside folder

Frank Barknecht fbar at footils.org
Fri Aug 30 16:11:33 CEST 2013


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:


- workdir/
  - main.pd    <- add [declare -path .] here and use as main patch
  - other.pd
  - mylib/
     filereader.pd
  - data1/
    - colors.txt
- data2/
  - colors.txt

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.

Ciao
-- 
 Frank Barknecht                                     _ ______footils.org__



More information about the Pd-list mailing list