I'm trying to read in a file containing a sinusoidal analysis, to provide control for additive synthesis. My patch creates a set of arrays (tables) for the frequency and magnitude values for as many partials as are described in the analysis file (which is generated by a separate program) via messages like [; pd-graph1 array $1-freqArray 100 float 0( . $1 comes from a counter which is reset when I read in a new file.
But once I create an array, it never goes away, and I end up with an ever increasing number of tables named 0-freqArray etc.
If you only need one array, why not just create that statically (personally I prefer the [table] object for data, I don't need to see), then load its content with "read"/"write" messages?
Example:
[table MyArray 100]
[read /tmp/data1.txt( | [s MyArray]
[read /tmp/data2.txt( | [s MyArray]
...
The textfiles should just contain the array contents, one number per line. Check out the file 15.array.pd and 16.more.arrays.pd in the docs for more on table manipulation.
If you need to "clean" the array at some point you can always send a [resize 1( which will also "wipe" it.
[resize 0( | [s MyArray]
(maybe there's a more finesse way of doing this though?)
Lorenzo