Structure subtlety

yanomano's picture

This is probably an idiotic question but, in a structure of structures, is there a way to retrieve the name of an index when the structure has been reordered ?

See the jpeg as example : The first index (0) is named "9" : how to retrieve this number/name ?

A method without javascript would be ideal because the work is done inside an iterator !

Thanks for the kind help !

PreviewAttachmentSize
Structure.jpg
Structure.jpg70.42 KB

cwright's picture
Re: Structure subtlety

Unfortunately, the only way to do this right now is via javascript.

I think there's a kineme patch that does this, but I don't know if it's released yet. (smokris can probably chime in on that one).

smokris's picture
Re: Structure subtlety

Yes, I posted a clip that does this: http://kineme.net/composition/smokris/StructureKeyIndex

(However, it does use Javascript. We don't currently have an equivalent Objective-C patch, but it should be pretty straightforward to create if performance deems it necessary.)

yanomano's picture
Re: Structure subtlety

Thanks for the link to the javascript, it's a very good start to quickly test the function !

dust's picture
Re: Structure subtlety

I'm not sure how large the structure is but you can do this with kineme structure tools. Basically you need to make two structures. the first structure is normal and the second structure has your keys stored as values from the first structure. think of them as a pair that go together. this way when you sort the structure a second structure is storing all the keys of the new structure. it's preety simple, just put two kineme structures next to each other and wire the second structure up and just swap keys for values on second struct. this way you can pull out the key as well. you can check my midi to note frequency converter in the repository. I'm using this trick to display the key with the value on screen. I'm not sure how this will work with mixed data types as the qc structure sort seems to like declared data types. using input splitters on the kineme structure will help. when I get to my computer I will look for a macro I made that does this.

PreviewAttachmentSize
structure key sort.qtz15.94 KB
Structure Sort By Key Values.qtz25.27 KB