3

I am trying to loop over an array called meta.

I am having issues with checking if an element exists. In this array sometimes the length is present and sometimes it is not. I am trying to get something like this to work:

for (i=1;i LTE ArrayLen(meta);i=i+1) {

    if (meta[i].length==undefined) {

       maxLen = '1';
    }
    else    
    {

       maxLen = meta[i].length;

    }

}

I cannot seem to get the syntax right.

1 Answer 1

6

I think you want a structkeyexists.

if (structkeyexists(meta[i],"length") ....
Sign up to request clarification or add additional context in comments.

2 Comments

Yup, that did it. I was playing with structkeyexists but I did not have the syntax correct. Thanks
For arrays, use this: ArrayIsDefined(array, elementIndex)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.