Javascript, polybuffer~, dict, and something about timing

mattyo's icon

Hi,

I wrote a little JS designed for a folder which contains other folders full of audiofiles. It does two things:

1. Creates a polybuffer~ containing the files in each folder.
2. Querying that polybuffer~, it makes a dict, containing a subdict for each file, in the format:

"subdict-name" :     {
        "bufname" : "buffer-name",
        "buflen" : float -- buffer-length
    }

Now, if I do this with one folder, it works fine most of the time. However, if I do it with a folder of folders, the dicts do not get filled. I get the subdict names, but no data:

"subdict-name" :     {

}

If I load the folder _again_, and the dicts are looking at polybuffer~s I've already created, they're filled just fine. At first, I thought the data from the polybuffer~ wasn't getting there by the time the next folder started loading, but the strange thing is that they post, so the JS has access to them, but doesn't put them in the dict.

Any comments, explanations, or suggestions welcome.

\M

Patch:

Max Patch
Copy patch and select New From Clipboard in Max.

polybuffer-from-folder.js
application/x-javascript 1.06 KB
Javascript