How to get the elements number in Array?

  • How many elements in Array?

    Example:

    <myarray
    name="friends"
    friend1="pedro"
    friend2="jose"
    friend3="alfredo"
    />

    1. How to get the "elements count"?

    In the help document, count is for "Get the current number of items in the array", but in this case is 1 (the item is "friends"). I need to get 3 (pedro,jose,alfredo). How?

    2. How to put more items to "myarray"?

    <myarray
    name="friends"
    friend1="pedro"
    (...)
    name="jobs"
    job1...
    job2...

    3. Links with krpano examples of array?

    Thanks a lot.

  • <friends name="pedro" job="..." address="..." />
    <friends name="jose" job="..." address="..." />
    <friends name="alfredo" job="..." address="..." />

    trace(friends.count); --> 3
    trace(friends[2].name); --> alfredo
    trace(friends[alfredo].job); --> ...

    set(friends[sancho].job,"pansa");
    trace(friends[3].name, friends[3].job); --> sancho pansa

  • thanx for the clarification, it's working for me too.
    now it looks like whatever I read in the documentation is written in another language I DO NOT UNDERSTAND even if I do speak English.
    It's also written with so many allusions and implications that is putting me to dismay. 8 years doing things with krpano, I'm still in copy and paste pieces + trial and error.
    *sad*

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!