Re: Multidimensional array issue

2021-03-08 Thread Phil Davis via use-livecode
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

2021-03-08 Thread Bob Sneidar via use-livecode
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

2021-03-08 Thread Mark Wieder via use-livecode

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

2021-03-08 Thread Ralph DiMola via use-livecode
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

2021-03-08 Thread Mark Wieder via use-livecode

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

2021-03-08 Thread Ralph DiMola via use-livecode
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

2021-03-08 Thread Ralph DiMola via use-livecode
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

2021-03-08 Thread HENRY LOWE via use-livecode
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: Printing borked for LC Linux?

2021-03-08 Thread Mark Wieder via use-livecode

On 1/16/21 10:30 AM, Richard Gaskin via use-livecode wrote:


This report for Linux Mint seems perhaps relevant:
https://quality.livecode.com/show_bug.cgi?id=21131


In my comment #13 on that bug report I suggest a workaround. Is that a 
possible way forward for you?


--
 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

2021-03-08 Thread Mark Wieder via use-livecode

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


Multidimensional array issue

2021-03-08 Thread HENRY LOWE via use-livecode
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] 
such as:

Local tArray, tStatus

Put tArray[“status”] into tStatus
If tStatus is empty then
put tArray[“status”][“text”] into tStatus
End if

I have discovered that if tArray[“status”][“text”] contains a value then 
tArray[“status”] is not empty (as expected), so my test fails. 

However the expression ‘the value of tArray[“status”]’ return empty and calling 
 - answer tArray[“status”] returns an empty (null) string.

Is this a bug or a (perhaps) a logical outcome of how LC implements arrays?

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.

Try the following in the message box: put "data" into tA["A"]["B"];answer 
tA["A"] is empty

The result is false! Livecode reports that tA[“A”] is not empty

However entering the following in the message box returns true!

 put "data" into tA["A"]["B"];answer the value of tA["A"] is empty

Henry


___
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


[ANN] This Week in LiveCode 257

2021-03-08 Thread panagiotis merakos via use-livecode
Hi all,

Read about new developments in LiveCode open source and the open source
community in today's edition of the "This Week in LiveCode" newsletter!

Read issue #257 here: http://bit.ly/38lT3mX

This is a weekly newsletter about LiveCode, focussing on what's been
going on in and around the open source project. New issues will be
released weekly on Mondays. We have a dedicated mailing list that will
deliver each issue directly to your e-mail, so you don't miss any!

If you have anything you'd like mentioned (a project, a discussion
somewhere, an upcoming event) then please get in touch.


-- 
Panagiotis Merakos 
LiveCode Software Developer

Everyone Can Create Apps 
___
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