Search code examples
axaptamicrosoft-dynamicsx++dynamics-ax-2012-r3

How to get one container from another container?


I have a container that includes many items and some of those items are containers. And I need to get those internal containers. What is the best practice fot that?

My solution is kinda ugly for me :(

container a = [1, 2, ["one","two","three"]];
container b;
int i;
;

for (i = 1; i <= conLen(a); i++)
{
    try
    {
        b = conPeek(a, i);
        info(strFmt("%1", conPeek(b,1)));//here should be some logic with b items
    }
    catch
    {
         info(strFmt("NOT A CONTAINER %1",  conPeek(a, i)));
    }
}

Thanks in advance!


Solution

  • Ok, it was really easy. But maybe it will be helpfull for someone in the future.

      if(typeOf(conPeek(a, i)) == Types::Container)
      {
            b = conPeek(a, i);
            info(strFmt("%1", conPeek(b,1)));
      }