structures question

alvarotrevinho's picture

hello everybodyy!! i have a question about structures a how to deal with them, for example i have one structure with 5 members, each member with 3 submembers? ( dont know how to say it) i would like to extract the 2 submember for the 5 members and to get one structure . Structure sort Can do it? how i need to use it because i don find the way, thanks in advance...

bernardo's picture
Re: structures question

hi alvaro its called a 2d structure. you can access it using the "Structure Index Member" but i am on leopard i guess its still there on snow.... to go two levels just use two Structure Index Member linked to each other and choose the right level. bernardo

alvarotrevinho's picture
Re: structures question

yes i know the structure index memeber, jeje, but the problem its that i woul like to extract all the members from the structure with the same key, not only one,,, any suggestion?

usefuldesign.au's picture
Re: structures question

The most obvious way to me is using a Javascript patch.

outStruct = new Object();
key = "whatever_you_want";
j = 0;
for (i in inStruct)
{
   if (i = key) {
      outStruct[j] = new Array();
      outStruct[j][1] = inStruct[i][1];
      outStruct[j][2] = inStruct[i][2];
      j++;
   }
}
result.Output = outStruct;

You could pre-sort the structure with a sort patch or a JS .sort method to speed up work on a very large structure and break when the index changes away from your key value. Not necessary with 5x3 elements!

Using patches other than JS, sort the structure by the first level value key. Then sample the resulting structure for first and last elements with the correct key and get their index, then cut the structure up with a Structure Range patch. A lot more hassle if you ask me.