Multidimensional array issue

HENRY LOWE hlowe at me.com
Mon Mar 8 19:25:32 EST 2021


Thanks Mark. There are two possible states:

tArray[“status”] holds a value and tArray[“status”][“text”] does not

or

tArray[“status”][“text”] holds a value and tArray[“status”] does not


My code is trying to do the following:

If tArray[“status”] does not hold a value then check if tArray[“status”][“text”] holds a value


The crux is how one reliably determines that an array member (e.g. tArray[“status”]) holds a value?

I would have assumed that if the array member does not hold a value then  - if tArray[member] is empty would always return true. However that does not appear to be the case if the array is multidimensional.


It appears that both tArray[“status”] is an array and tArray[“status”][“text”] is an array are true. Am I missing something about using this syntax?

Thanks,

Henry


> On Mar 8, 2021, at 3:56 PM, Mark Wieder via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> On 3/8/21 3:46 PM, HENRY LOWE via use-livecode wrote:
> 
>> I have often used the form 'if tArray[“key1”] is empty' to determine whether an array element hold a value but this breaks if tArray[“key1”][“key2”] holds a value.
> 
> Same here. Not that I've every liked that paradigm, just that it's been that way since life crawled out of the ocean.
> 
> However this should do the trick.
> 
> if tArray["status"] is an array then
>  put tArray["status"]["text"] into tStatus
> else
>  put tArray["status"] into tStatus
> end if
> 
> -- 
> Mark Wieder
> ahsoftware at gmail.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list