Re: Multidimensional array issue
Thank you to everyone for help in resolving this issue. The syntax for determining if tArray[“status”] contains data or an array appears to be either: If the value of tArray[“status”] is not empty // contains data or If tArray[“status”] is not an array // contains data If I remember correctly, LC arrays are implemented as associative arrays (key, value pairs). I assume that they are implemented as hash tables as opposed to trees? Henry > On Mar 10, 2021, at 9:06 AM, Bob Sneidar via use-livecode > wrote: > > What he said. :-) > > Bob S > > > On Mar 9, 2021, at 10:19 AM, Ralph DiMola via use-livecode > mailto:use-livecode@lists.runrev.com>> wrote: > > If (not(tArray[“status”] is an array)) and (tArray[“status”] is not empty) > then -- ***tArray[“status”] is not an array and is not empty. > As MW said empty is technically a value. > > ___ > 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
Re: Multidimensional array issue
>> (tArray["key1","key1.1"]["key2","key2.1"]) Sean never even thought about this form of arrays. I gotta test the functionality of this. Thanks. I know you are busy, but if you have the time, feel free to blow my mind. On Wed, Mar 10, 2021 at 8:12 PM Sean Cole (Pi) via use-livecode < use-livecode@lists.runrev.com> wrote: > In the message box: > > > > > put "data" into tArray["key1"]["key2"]; answer the value of > tArray["key1”] > > - returns EMPTY (so this works) > > Correct > > put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is empty - > > returns FALSE (it should return true IMHO) > > Because it is not empty. It has a nested array in it. If it where empty > (TRUE) then it would be void of all data of all types. > > put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is an array - > > returns TRUE (so not helpful) > > tArray is an array; > tArray["key1"] is an array (because it has ["key2"] within; > tArray["key1"]["key2"] is not an array (unless you put an array into it) > > To make this clearer: > > put "hello" into tArray-- tArray is not an array > > put tArray; // returns "hello" > > tArray contains a value = true > > tArray is empty = false -- it contains a value > tArray["key1"] is empty = true -- it does not exist > tArray["key1"]["key2"] is empty = true -- it does not exist > > > put "hello" into tArray["key1"]-- tArray is an array ; tArray["key1"] > is not an array > > put tArray; // returns empty > > put tArray["key1"]; // returns "hello" > > tArray contains a value = false > tArray["key1"] contains a value = true > tArray is empty = false -- it contains an array > tArray["key1"] is empty = false -- it contains a value > > tArray["key1"]["key2"] is empty = true -- it does not exist > > > put "hello" into tArray["key1"]["key2"]-- ttArray is an array > ; tArray["key1"] is an array ; tArray["key1"]["key2"] is not an array > > put tArray; // returns empty > > put tArray["key1"]; // returns empty > put tArray["key1"]["key2"]; // returns "hello" > > tArray contains a value = false > tArray["key1"] contains a value = false > tArray["key1"]["key2"] contains a value = true > tArray is empty = false -- it contains an array > tArray["key1"] is empty = false -- it contains an array > tArray["key1"]["key2"] is empty = false -- it contains a value > > put "hello" into tArray-- tArray is not an array; it has been reset to > a value nullifying it's array status and values > > put tArray; // returns "hello" > > tArray contains a value = true > > tArray is empty = false -- it contains a value > tArray["key1"] is empty = true -- it does not exist > tArray["key1"]["key2"] is empty = true -- it does not exist > > put "hello" into tArray > put "hello" into tArray["key2"] > put tArray into tArray["key1"] > tArray = > > ["key1"] > ["key2"] > "hello" > ["key2"] > "hello" > > That just about covers it. Unless I go into super sub arrays to really blow > your mind (tArray["key1","key1.1"]["key2","key2.1"]) > > Sean > ___ > 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 > -- Tom Glod Founder & Developer MakeShyft R.D.A (www.makeshyft.com) Mobile:647.562.9411 ___ 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
Re: Multidimensional array issue
In the message box: > put "data" into tArray["key1"]["key2"]; answer the value of tArray["key1”] > - returns EMPTY (so this works) Correct put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is empty - > returns FALSE (it should return true IMHO) Because it is not empty. It has a nested array in it. If it where empty (TRUE) then it would be void of all data of all types. put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is an array - > returns TRUE (so not helpful) tArray is an array; tArray["key1"] is an array (because it has ["key2"] within; tArray["key1"]["key2"] is not an array (unless you put an array into it) To make this clearer: put "hello" into tArray-- tArray is not an array put tArray; // returns "hello" tArray contains a value = true tArray is empty = false -- it contains a value tArray["key1"] is empty = true -- it does not exist tArray["key1"]["key2"] is empty = true -- it does not exist put "hello" into tArray["key1"]-- tArray is an array ; tArray["key1"] is not an array put tArray; // returns empty put tArray["key1"]; // returns "hello" tArray contains a value = false tArray["key1"] contains a value = true tArray is empty = false -- it contains an array tArray["key1"] is empty = false -- it contains a value tArray["key1"]["key2"] is empty = true -- it does not exist put "hello" into tArray["key1"]["key2"]-- ttArray is an array ; tArray["key1"] is an array ; tArray["key1"]["key2"] is not an array put tArray; // returns empty put tArray["key1"]; // returns empty put tArray["key1"]["key2"]; // returns "hello" tArray contains a value = false tArray["key1"] contains a value = false tArray["key1"]["key2"] contains a value = true tArray is empty = false -- it contains an array tArray["key1"] is empty = false -- it contains an array tArray["key1"]["key2"] is empty = false -- it contains a value put "hello" into tArray-- tArray is not an array; it has been reset to a value nullifying it's array status and values put tArray; // returns "hello" tArray contains a value = true tArray is empty = false -- it contains a value tArray["key1"] is empty = true -- it does not exist tArray["key1"]["key2"] is empty = true -- it does not exist put "hello" into tArray put "hello" into tArray["key2"] put tArray into tArray["key1"] tArray = ["key1"] > ["key2"] > "hello" ["key2"] > "hello" That just about covers it. Unless I go into super sub arrays to really blow your mind (tArray["key1","key1.1"]["key2","key2.1"]) Sean ___ 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
Re: Multidimensional array issue
This is a very interesting discussion of LC arrays. But back to the original post: > HENRY LOWE wrote: > > I am using multidimensional arrays to process data read from JSON files. > Some of the data in the JSON files can be represented in alternative forms in > files from different sources. > For example a field named ?status? may be represented as either: > "status": { >"text":"active"} > > or > "status": {"active"} > > To recognize both forms I use code (after transforming JSON to an array > tArray] Perhaps massage the JSON before importing it into an array. replace quote & "text" & quote & ":" with empty in myJSON In this way there won't need to distinguish "alternate forms" in the LC array. Jim Lambert ___ 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
Re: Multidimensional array issue
What he said. :-) Bob S On Mar 9, 2021, at 10:19 AM, Ralph DiMola via use-livecode mailto:use-livecode@lists.runrev.com>> wrote: If (not(tArray[“status”] is an array)) and (tArray[“status”] is not empty) then -- ***tArray[“status”] is not an array and is not empty. As MW said empty is technically a value. ___ 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
Re: Multidimensional array issue
If tArray [“status”] is an array or tArray [“status”] is not empty It’s an odd array structure though if a key can contain either. Bob S On Mar 9, 2021, at 10:02 AM, HENRY LOWE via use-livecode mailto:use-livecode@lists.runrev.com>> wrote: Thanks to all for your excellent discussion and suggestions. To briefly restate the problem: If tArray[“status”] does not contain a value and If tArray[“status”][“text”] contains a value How do I determine if tArray[“status”] contains a value? ___ 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
Re: Multidimensional array issue
On 3/9/21 10:02 AM, HENRY LOWE via use-livecode wrote: put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is an array - returns TRUE (so not helpful) Not sure why this isn't helpful. Of course it's an array. And tArray["key1"]["key2"] is *not* an array and contains the value. Nonetheless, I think Brian's suggestion may be the easiest to grok. -- 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
RE: Multidimensional array issue
If (not(tArray[“status”] is an array)) and (tArray[“status”] is not empty) then -- ***tArray[“status”] is not an array and is not empty. As MW said empty is technically a value. If you want to know if tArray[“status”] exists and is a value (empty or not) then this should work: If (“status” is among the lines of the keys of tArray) and ( not (tArray[“status”] is an array)) then -- tArray[“status”] exists as a value (empty or not) 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: Tuesday, March 09, 2021 1:03 PM To: Nabble-Livecode-List Cc: HENRY LOWE Subject: Re: Multidimensional array issue Thanks to all for your excellent discussion and suggestions. To briefly restate the problem: If tArray[“status”] does not contain a value and If tArray[“status”][“text”] contains a value How do I determine if tArray[“status”] contains a value? In the message box: put "data" into tArray["key1"]["key2"]; answer the value of tArray["key1”] - returns EMPTY (so this works) put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is empty - returns FALSE (it should return true IMHO) put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is an array - returns TRUE (so not helpful) Henry > On Mar 8, 2021, at 5:36 PM, Bob Sneidar via use-livecode > wrote: > > Are you testing for empty, or are you testing if there is a value in an array > variable? If there is no key matching your array variable, LC will return an > empty string. An empty string is a value. > > Mark is using a different method, seeing if a key of an array is itself an > array. If bobtest ["value"] contains another array so that bobtest ["value"] > ["anumber"] contains 1, then bobtest ["value"] is an array. If bobtest > ["value"] contains 1 then it is not an array. > > But getting the value of bobtest ["value"] ["number"] will return empty > whether or not bobtest '{value"] is an array. This is why Mark is testing for > an array rather than the value. > > It seems a bit wonky, you might think, "Why not return an error?" But trust > me, when you work with arrays, especially when it comes to datagrid data, > this is the best course. > > Bob S > > >> On Mar 8, 2021, at 16:25 , HENRY LOWE via use-livecode >> wrote: >> >> 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 >>> 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 >>> subscriptio
Re: Multidimensional array issue
Try this: put tArray[“status”][“text”] into tStatus If tStatus is empty then Put tArray[“status”] into tStatus End if Sent from my iPhone ___ 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
Re: Multidimensional array issue
Thanks to all for your excellent discussion and suggestions. To briefly restate the problem: If tArray[“status”] does not contain a value and If tArray[“status”][“text”] contains a value How do I determine if tArray[“status”] contains a value? In the message box: put "data" into tArray["key1"]["key2"]; answer the value of tArray["key1”] - returns EMPTY (so this works) put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is empty - returns FALSE (it should return true IMHO) put "data" into tArray["key1"]["key2"]; answer tArray["key1”] is an array - returns TRUE (so not helpful) Henry > On Mar 8, 2021, at 5:36 PM, Bob Sneidar via use-livecode > wrote: > > Are you testing for empty, or are you testing if there is a value in an array > variable? If there is no key matching your array variable, LC will return an > empty string. An empty string is a value. > > Mark is using a different method, seeing if a key of an array is itself an > array. If bobtest ["value"] contains another array so that bobtest ["value"] > ["anumber"] contains 1, then bobtest ["value"] is an array. If bobtest > ["value"] contains 1 then it is not an array. > > But getting the value of bobtest ["value"] ["number"] will return empty > whether or not bobtest '{value"] is an array. This is why Mark is testing for > an array rather than the value. > > It seems a bit wonky, you might think, "Why not return an error?" But trust > me, when you work with arrays, especially when it comes to datagrid data, > this is the best course. > > Bob S > > >> On Mar 8, 2021, at 16:25 , HENRY LOWE via use-livecode >> wrote: >> >> 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 >>> 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 ___ 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
Re: Multidimensional array issue
Thanks to all for your excellent discussion and suggestions. To briefly restate the problem: If tArray[=E2=80=9Cstatus=E2=80=9D] does not contain a value and If tArray[=E2=80=9Cstatus=E2=80=9D][=E2=80=9Ctext=E2=80=9D] contains a = value How do I determine if tArray[=E2=80=9Cstatus=E2=80=9D] contains a value? In the message box: put "data" into tArray["key1"]["key2"]; answer the value of = tArray["key1=E2=80=9D] - returns EMPTY (so this works) put "data" into tArray["key1"]["key2"]; answer tArray["key1=E2=80=9D] is = empty - returns FALSE (it should return true IMHO)=20 put "data" into tArray["key1"]["key2"]; answer tArray["key1=E2=80=9D] is = an array - returns TRUE (so not helpful)=20 Henry > On Mar 8, 2021, at 4:54 PM, Mark Wieder via use-livecode > wrote: > > On 3/8/21 4:25 PM, HENRY LOWE via use-livecode wrote: > >> My code is trying to do the following: > > No, I *do* see what you're trying to do. > Here... try it for yourself: > > on mouseUp pMouseBtnNo > local tArray > > put "hello" into tArray["status"] > put tArray["status"] is an array into msg # false > breakpoint > put tArray["status"]["text"] is an array into msg # false > breakpoint > put "goodbye" into tArray["status"]["text"] > put tArray["status"] is an array into msg # true > breakpoint > put tArray["status"]["text"] is an array into msg # false > breakpoint > end mouseUp > > ...or Ralph's version will also do the trick. > > -- > 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
RE: Multidimensional array issue
If “item” is among the lines of the keys of tDataA and tDataA [“item”] is empty then --it's an array key with an empty value. 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 Bob Sneidar via use-livecode Sent: Tuesday, March 09, 2021 12:24 PM To: How to use LiveCode Cc: Bob Sneidar Subject: Re: Multidimensional array issue The trouble is, if tDataA [“item”] variable does not exist, that is it is not an array, you will still get empty. Bob S On Mar 8, 2021, at 9:16 PM, Phil Davis via use-livecode mailto:use-livecode@lists.runrev.com>> wrote: When I want to determine whether or not an array element contains non-whitespace, I usually say: if word 1 of tDataA["item"] is empty then ... (or is NOT empty) Just another option. Phil Davis ___ 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
Re: Multidimensional array issue
The trouble is, if tDataA [“item”] variable does not exist, that is it is not an array, you will still get empty. Bob S On Mar 8, 2021, at 9:16 PM, Phil Davis via use-livecode mailto:use-livecode@lists.runrev.com>> wrote: When I want to determine whether or not an array element contains non-whitespace, I usually say: if word 1 of tDataA["item"] is empty then ... (or is NOT empty) Just another option. Phil Davis ___ 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
Re: Multidimensional array issue
You might also want to make use of the 'strictly' keyword in case there are any nested arrays in your base array. Your use case may not venture that far but it is maybe worth just applying it anyway. *put* (atest is strictly an array) Sean On Tue, 9 Mar 2021 at 16:09, Sean Cole (Pi) wrote: > *put* empty into atest["test1"]; > > *put* 1 into atest["test2"]; > > *put* 3 into atest["test3"]["test3.1"]; > > *put* (atest is an array) , (atest["test1"] is an array) , (atest["test2"] > is an array) , (atest["test3"] is an array) > > > true,false,false,true > > > Seems fine to me. > > Sean > ___ 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
Re: Multidimensional array issue
On 3/8/21 9:16 PM, Phil Davis via use-livecode wrote: When I want to determine whether or not an array element contains non-whitespace, I usually say: if word 1 of tDataA["item"] is empty then ... (or is NOT empty) The problem with that is that it doesn't differentiate between an empty array element and a nonexisting one: local tArray put empty into tArray["foo"] put word 1 of tArray["foo"] is empty # true put word 1 of tArray["bar"] is empty # true breakpoint # will show that only tArray["foo"] exists -- 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
Re: Multidimensional array issue
*put* empty into atest["test1"]; *put* 1 into atest["test2"]; *put* 3 into atest["test3"]["test3.1"]; *put* (atest is an array) , (atest["test1"] is an array) , (atest["test2"] is an array) , (atest["test3"] is an array) true,false,false,true Seems fine to me. Sean ___ 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
Re: Multidimensional array issue
Er, I think I have just reached the fourth level of array un-enlightenment. Wait!…. I can see the cyberverse! SCHLOOOppp!-ting! > On 3/8/21 5:36 PM, Bob Sneidar via use-livecode wrote: >> Are you testing for empty, or are you testing if there is a value in an >> array variable? If there is no key matching your array variable, LC will >> return an empty string. An empty string is a value. >> >> Mark is using a different method, seeing if a key of an array is itself an >> array. If bobtest ["value"] contains another array so that bobtest ["value"] >> ["anumber"] contains 1, then bobtest ["value"] is an array. If bobtest >> ["value"] contains 1 then it is not an array. >> >> But getting the value of bobtest ["value"] ["number"] will return empty >> whether or not bobtest '{value"] is an array. This is why Mark is testing >> for an array rather than the value. >> >> It seems a bit wonky, you might think, "Why not return an error?" But trust >> me, when you work with arrays, especially when it comes to datagrid data, >> this is the best course. >> >> Bob S >> >> >>> On Mar 8, 2021, at 16:25 , HENRY LOWE via use-livecode >>> wrote: >>> >>> 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 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 > > -- > Phil Davis > 503-307-4363 > > > ___ > 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
Re: Multidimensional array issue
When I want to determine whether or not an array element contains non-whitespace, I usually say: if word 1 of tDataA["item"] is empty then ... (or is NOT empty) Just another option. Phil Davis On 3/8/21 5:36 PM, Bob Sneidar via use-livecode wrote: Are you testing for empty, or are you testing if there is a value in an array variable? If there is no key matching your array variable, LC will return an empty string. An empty string is a value. Mark is using a different method, seeing if a key of an array is itself an array. If bobtest ["value"] contains another array so that bobtest ["value"] ["anumber"] contains 1, then bobtest ["value"] is an array. If bobtest ["value"] contains 1 then it is not an array. But getting the value of bobtest ["value"] ["number"] will return empty whether or not bobtest '{value"] is an array. This is why Mark is testing for an array rather than the value. It seems a bit wonky, you might think, "Why not return an error?" But trust me, when you work with arrays, especially when it comes to datagrid data, this is the best course. Bob S On Mar 8, 2021, at 16:25 , HENRY LOWE via use-livecode wrote: 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 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 -- Phil Davis 503-307-4363 ___ 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
Re: Multidimensional array issue
Are you testing for empty, or are you testing if there is a value in an array variable? If there is no key matching your array variable, LC will return an empty string. An empty string is a value. Mark is using a different method, seeing if a key of an array is itself an array. If bobtest ["value"] contains another array so that bobtest ["value"] ["anumber"] contains 1, then bobtest ["value"] is an array. If bobtest ["value"] contains 1 then it is not an array. But getting the value of bobtest ["value"] ["number"] will return empty whether or not bobtest '{value"] is an array. This is why Mark is testing for an array rather than the value. It seems a bit wonky, you might think, "Why not return an error?" But trust me, when you work with arrays, especially when it comes to datagrid data, this is the best course. Bob S > On Mar 8, 2021, at 16:25 , HENRY LOWE via use-livecode > wrote: > > 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 >> 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
Re: Multidimensional array issue
On 3/8/21 4:58 PM, Ralph DiMola via use-livecode wrote: Also works, if tArray[“status”] an array -- It's an array if (not (tArray[“status”] an array)) and (tArray[“status”] is not empty) -- it's a value Well, technically "empty" is also a value. Just an... er... empty one. -- 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
RE: Multidimensional array issue
Also works, if tArray[“status”] an array -- It's an array if (not (tArray[“status”] an array)) and (tArray[“status”] is not empty) -- it's a value 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 > 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
Re: Multidimensional array issue
On 3/8/21 4:25 PM, HENRY LOWE via use-livecode wrote: My code is trying to do the following: No, I *do* see what you're trying to do. Here... try it for yourself: on mouseUp pMouseBtnNo local tArray put "hello" into tArray["status"] put tArray["status"] is an array into msg # false breakpoint put tArray["status"]["text"] is an array into msg # false breakpoint put "goodbye" into tArray["status"]["text"] put tArray["status"] is an array into msg # true breakpoint put tArray["status"]["text"] is an array into msg # false breakpoint end mouseUp ...or Ralph's version will also do the trick. -- 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
RE: Multidimensional array issue
Typed too fast(left out a "the") If the number lines of the 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 > 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
RE: Multidimensional array issue
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 > 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
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 > 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
Re: Multidimensional array issue
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