Caution: This documentation is for Exponential, from version 3.x to 6.x.
For 5.x documentation covering Platform see Exponential Platform Documentation, for difference between legacy and Platform see 5.x Architecture overview.

Array inspection

How can I inspect all values of the array when I do not know its size? There are cases when the array is generated dynamically, and I do not know its size.
  • Re: Array inspection

    You can use the FOREACH construct.
  • Re: Array inspection

    Yes, "foreach" is the common idea, but you can also use the function "get_type()" to show the length. Here is an example:

    {def $somearray=...}
    {def $length=$somearray|get_type()}

    {for 0 to $length as $counter}
    {$somearray[$counter]}
    {/for}

    {undef}

    This is more helpful if you want to access the neighbour elements of the actual element, for example. If you do not need a counte, "foreach" is easier to use.

Anonymous User (29/06/2006 6:22 am)

Anonymous User (29/06/2006 6:22 am)


Comments

  • Re: Array inspection

    You can use the FOREACH construct.
  • Re: Array inspection

    Yes, "foreach" is the common idea, but you can also use the function "get_type()" to show the length. Here is an example:

    {def $somearray=...}
    {def $length=$somearray|get_type()}

    {for 0 to $length as $counter}
    {$somearray[$counter]}
    {/for}

    {undef}

    This is more helpful if you want to access the neighbour elements of the actual element, for example. If you do not need a counte, "foreach" is easier to use.