If the number lines of keys of tArray[“status”] > 0 -- It's an array

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-----Original Message-----
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of 
HENRY LOWE via use-livecode
Sent: Monday, March 08, 2021 7:26 PM
To: Nabble-Livecode-List
Cc: HENRY LOWE
Subject: Re: Multidimensional array issue

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@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
> ahsoftw...@gmail.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to