Re: Sorting Arrays

2023-08-12 Thread Bob Sneidar via use-livecode
I formatted the sortKeys as I would an SQL query or an LC sort, but then I 
needed to isolate the key from the parameters because I couldn’t assume the 
sort key was simply the first word. 

Sent from my iPhone

> On Aug 12, 2023, at 09:36, J. Landman Gay via use-livecode 
>  wrote:
> 
> I used a short, one-dimensional numbered array:
> 
> put the weekdayNames into tDataA
> split tDataA by cr
> simpleSortNumberedArray tDataA, "descending,text"
> 
> But as Alex explained, one dimension wasn't enough.
> 
> --
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>> On August 11, 2023 7:09:50 PM Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> Send me what you have. Thanks.
>> 
>> Sent from my iPhone
>> 
 On Aug 11, 2023, at 17:02, Alex Tweedly via use-livecode 
  wrote:
>>> 
>>> ?
 On 11/08/2023 23:00, J. Landman Gay via use-livecode wrote:
 On 8/10/23 2:29 PM, Alex Tweedly via use-livecode wrote:
 [ ... code from earlier posting ...]
>>> 
 I couldn't get this to work until I altered it, but I was using a very 
 simple array. What type of array data did you use? I think I'm missing 
 something.
 
 I just did this:
 
  put the weekdayNames into tDataA
  split tDataA by cr
  simpleSortNumberedArray tDataA, "descending,text"
 
>>> What you're missing is that this (simpleSortNumberedArray) is only intended 
>>> for "numbered array"s (which LC is calling "sequences" in some places); 
>>> i.e. an array where the (top-level) keys are all consecutive integers, from 
>>> 1  n
>>> 
>>> Also, the pSortkeys should be a number of comma-separated items, each of 
>>> which consists of a key by which you want to sort the array followed 
>>> optionally by an order and type.
>>> 
>>> So you might do something like :
>>> 
 on mouseup
   local tCounter, tDataA
 
   repeat for each line L in the weekdayNames
  add 1 to tCounter
  put L into tDataA[tCounter]["dayname"]
  put the number of chars in L into tDataA[tCounter]["charcount"]
   end repeat
 
   -- sorts ascending by name (i.e. F, M, Sa, Su, Th, Tu, W)
   simpleSortNumberedArray tDataA, "dayname"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat
 
   put "-"  after msg
 
   -- sorts descending numeric by number of characters in name
   --  NB within each char count value, they remain in alphabetical order 
 of name
   simpleSortNumberedArray tDataA, "charcount numeric descending"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat
 end mouseup
>>> and get as output
>>> 
 6 Friday
 6 Monday
 8 Saturday
 6 Sunday
 8 Thursday
 7 Tuesday
 9 Wednesday
 -
 9 Wednesday
 8 Saturday
 8 Thursday
 7 Tuesday
 6 Friday
 6 Monday
 6 Sunday
>>> 
>>> So - it would be worth adding a check that the array passed in is indeed a 
>>> sequence, at the start of simpleSortNumberedArray:
>>> 
>>> if NOT (pArrayDataA is an array AND \
>>>   item 2 of extents(pArrayDataA) is the number of elements in 
>>> pArrayDataA) then \
>>> return pArrayData
>>> 
>>> I'm now going to add this to my personal library, but I'll rename it to
>>> 
>>>seqSortMultipleKeys
>>> 
>>> Alex.
>>> 
>>> 
>>> 
>>> ___
>>> 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: Sorting Arrays

2023-08-12 Thread J. Landman Gay via use-livecode

I used a short, one-dimensional numbered array:

put the weekdayNames into tDataA
split tDataA by cr
simpleSortNumberedArray tDataA, "descending,text"

But as Alex explained, one dimension wasn't enough.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On August 11, 2023 7:09:50 PM Bob Sneidar via use-livecode 
 wrote:



Send me what you have. Thanks.

Sent from my iPhone

On Aug 11, 2023, at 17:02, Alex Tweedly via use-livecode 
 wrote:


?

On 11/08/2023 23:00, J. Landman Gay via use-livecode wrote:
On 8/10/23 2:29 PM, Alex Tweedly via use-livecode wrote:
[ ... code from earlier posting ...]


I couldn't get this to work until I altered it, but I was using a very 
simple array. What type of array data did you use? I think I'm missing 
something.


I just did this:

  put the weekdayNames into tDataA
  split tDataA by cr
  simpleSortNumberedArray tDataA, "descending,text"

What you're missing is that this (simpleSortNumberedArray) is only intended 
for "numbered array"s (which LC is calling "sequences" in some places); 
i.e. an array where the (top-level) keys are all consecutive integers, from 
1  n


Also, the pSortkeys should be a number of comma-separated items, each of 
which consists of a key by which you want to sort the array followed 
optionally by an order and type.


So you might do something like :


on mouseup
   local tCounter, tDataA

   repeat for each line L in the weekdayNames
  add 1 to tCounter
  put L into tDataA[tCounter]["dayname"]
  put the number of chars in L into tDataA[tCounter]["charcount"]
   end repeat

   -- sorts ascending by name (i.e. F, M, Sa, Su, Th, Tu, W)
   simpleSortNumberedArray tDataA, "dayname"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat

   put "-"  after msg

   -- sorts descending numeric by number of characters in name
   --  NB within each char count value, they remain in alphabetical order of 
name
   simpleSortNumberedArray tDataA, "charcount numeric descending"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat
end mouseup

and get as output


6 Friday
6 Monday
8 Saturday
6 Sunday
8 Thursday
7 Tuesday
9 Wednesday
-
9 Wednesday
8 Saturday
8 Thursday
7 Tuesday
6 Friday
6 Monday
6 Sunday


So - it would be worth adding a check that the array passed in is indeed a 
sequence, at the start of simpleSortNumberedArray:


if NOT (pArrayDataA is an array AND \
   item 2 of extents(pArrayDataA) is the number of elements in 
pArrayDataA) then \
 return pArrayData

I'm now going to add this to my personal library, but I'll rename it to

seqSortMultipleKeys

Alex.



___
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: Sorting Arrays

2023-08-12 Thread J. Landman Gay via use-livecode

Got it, thanks. The array was numbered but I didn't have enough dimensions.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On August 11, 2023 7:03:33 PM Alex Tweedly via use-livecode 
 wrote:



On 11/08/2023 23:00, J. Landman Gay via use-livecode wrote:

On 8/10/23 2:29 PM, Alex Tweedly via use-livecode wrote:
[ ... code from earlier posting ...]



I couldn't get this to work until I altered it, but I was using a very
simple array. What type of array data did you use? I think I'm missing
something.

I just did this:

  put the weekdayNames into tDataA
  split tDataA by cr
  simpleSortNumberedArray tDataA, "descending,text"


What you're missing is that this (simpleSortNumberedArray) is only
intended for "numbered array"s (which LC is calling "sequences" in some
places); i.e. an array where the (top-level) keys are all consecutive
integers, from 1  n

Also, the pSortkeys should be a number of comma-separated items, each of
which consists of a key by which you want to sort the array followed
optionally by an order and type.

So you might do something like :


on mouseup
   local tCounter, tDataA

   repeat for each line L in the weekdayNames
  add 1 to tCounter
  put L into tDataA[tCounter]["dayname"]
  put the number of chars in L into tDataA[tCounter]["charcount"]
   end repeat

   -- sorts ascending by name (i.e. F, M, Sa, Su, Th, Tu, W)
   simpleSortNumberedArray tDataA, "dayname"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat

   put "-"  after msg

   -- sorts descending numeric by number of characters in name
   --  NB within each char count value, they remain in alphabetical
order of name
   simpleSortNumberedArray tDataA, "charcount numeric descending"
   repeat with I = 1 to 7
  put tDataA[I]["charcount"] && tDataA[I]["dayname"] & CR after msg
   end repeat
end mouseup

and get as output


6 Friday
6 Monday
8 Saturday
6 Sunday
8 Thursday
7 Tuesday
9 Wednesday
-
9 Wednesday
8 Saturday
8 Thursday
7 Tuesday
6 Friday
6 Monday
6 Sunday


So - it would be worth adding a check that the array passed in is indeed
a sequence, at the start of simpleSortNumberedArray:

if NOT (pArrayDataA is an array AND \
   item 2 of extents(pArrayDataA) is the number of elements in
pArrayDataA) then \
 return pArrayData

I'm now going to add this to my personal library, but I'll rename it to

seqSortMultipleKeys

Alex.



___
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: Android black screen again...

2023-08-12 Thread Klaus major-k via use-livecode
Hi Jacque,

you wrote:

> I'm just guessing, but memory may be too low to allow the browser widget to 
> work,

however I am not using the browser widget (does not display PDFs on Andoid!)
but the PDF widget!

> Am 11.08.2023 um 22:30 schrieb J. Landman Gay via use-livecode 
> :
> 
> On 8/11/23 3:12 AM, Klaus major-k via use-livecode wrote:
>> The problem is that this is not reproducable, it happens out of a sudden if 
>> it happens.
>> Even the hardware BACKKEY does not work in that situation, only the HOMEKEY 
>> so I can
>> at least quit the app.
> 
> That's called an ANR ("Application Not Responding"). Something in the app is 
> causing a hang. If you wait long enough, Android should put up a dialog 
> asking if you want to wait or close the app. If you choose to wait, sometimes 
> it comes back. However, the wait can be 10-20 seconds or more so people often 
> just quit before the dialog appears.

OK, if I have the time I will wait next time and see what happens.

> The problem here is figuring out what causes it. Is it always the same PDF 
> file? Or maybe it happens after opening a certain number of files, or the 
> length of a file, or the cumulative length of several files, or...? If it 
> isn't reproducible, it's very difficult to find the cause.

It happen when I start the app, at that point there is no PDF loaded, just the 
"start card"
with a couple of poly grids.

It also happened in the same "session", means no switching the device off and 
on again.
I started the device then opened my app, no problems.
Then I quit my app and started again, BOOM, black screen.

> If it happens to you at home some day, see if waiting 15 seconds or more puts 
> up that dialog. That would confirm it's an ANR.

Yes, will do, thanks for the hint!

> -- 
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com

Best

Klaus

--
Klaus Major
https://www.major-k.de
https://www.major-k.de/bass
kl...@major-k.de


___
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