Max capacity of a field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Max capacity of a field

Post by dunbarx » Thu Sep 10, 2020 9:39 pm

This started with another thread in this pane:
http://forums.livecode.com/viewtopic.php?f=9&t=34623

I made a test stack, one button and two fields, with this in the button script:

Code: Select all

on mouseUp
   put the seconds into tStart
   put "1234567890" into temp -- ten chars
   repeat 100000 -- a 1,000,000 char test
      put temp after accum
   end repeat
  
   put accum into fld 1
   put the seconds -tStart into fld 2
end mouseUp
I got the beachBall, and the Mac dialog "Force Quit Applications" showed LiveCode "not responding". We have all seen that sort of thing. I force-quit LC, thinking it had hung.

So I knocked the repeat value down to 10,000, got a mere flash of a beachBall and then 100,000 chars were loaded into the field. So I increased the repeat value in steps, and, though the beachBall lasted longer, I got a repeat value of 50,000 (500,000 chars) to load successfully. It took a couple of minutes though, and the "Not Responding" was in the dialog the whole time. That cleared when the process finally completed. But someone would have thought that the process has failed, when in fact my machine and LC were just not talking to each other.

They eventually made up.

I then re-tried 100,000 for a repeat value (1,000,000 chars), and that took 14 minutes. Larger repeat values require longer than linear times, so I am stopping at the one million character test. I suspect that time notwithstanding, there may be no such limit.

But if I learned anything, it was that an app like LC that is "not responding" may in fact just be very busy, and the machine is misinterpreting that to mean it has gone off into the weeds. It may have, of course, but it seems to have always been able to find its way back.

On another note, I have a card with a field that already contains 1,760.000 chars. It takes LC about seven seconds, with the beachBall showing up for the occasion, to display that card.

Craig

SparkOut
Posts: 2949
Joined: Sun Sep 23, 2007 4:58 pm

Re: Max capacity of a field

Post by SparkOut » Thu Sep 10, 2020 9:47 pm

The "not responding" issue is typical on Windows when a tight repeat loop hogs all the cycles. This is why I frequently mention including a line inside the loop

Code: Select all

wait 0 milliseconds with messages
I had heard this was originally "a Mac thing" that got resolved. But it has always been "a thing" on Windows, and still is.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Max capacity of a field

Post by dunbarx » Fri Sep 11, 2020 12:23 am

Sparkout.

I will try this and see if it prevents the appearance of the "not responding" gizmo.

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Max capacity of a field

Post by bn » Fri Sep 11, 2020 1:38 am

dunbarx wrote:
Thu Sep 10, 2020 9:39 pm
This started with another thread in this pane:
http://forums.livecode.com/viewtopic.php?f=9&t=34623

I made a test stack, one button and two fields, with this in the button script:

Code: Select all

on mouseUp
   put the seconds into tStart
   put "1234567890" into temp -- ten chars
   repeat 100000 -- a 1,000,000 char test
      put temp after accum
   end repeat
  
   put accum into fld 1
   put the seconds -tStart into fld 2
end mouseUp
I got the beachBall, and the Mac dialog "Force Quit Applications" showed LiveCode "not responding". We have all seen that sort of thing. I force-quit LC, thinking it had hung.
Craig,

what you are testing is the limit of the length of a line in Livecode. I am surprised it did not crash. I think it is 64000 something and the formattedWidth is about half of it. See user guide. Your code produces one line.

Try adding a return after each 10 chars = temp

Code: Select all

on mouseUp
   put the seconds into tStart
   put "1234567890" into temp -- ten chars
   repeat 100000 -- a 1,000,000 char test
      put temp & cr after accum
   end repeat
   
   put accum into fld 1
   put the seconds -tStart into fld 2
end mouseUp
those 1.1 million chars (including returns) take about 1 second

Kind regards
Bernd

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Max capacity of a field

Post by FourthWorld » Fri Sep 11, 2020 2:58 am

Natural language, or anything with white space, is a much better test to run than a long 10MB string with no spaces or returns.

LC has a known issue attempting to render a string > ~64k (which in the real world is seldom exceeded) with no white space, and the internal routines to attempt line-wrapping are, I'm told, not trivial.

So at a minimum you'll want to have a reasonable amount of spaces in that test data.

And if you're looking at load performance independent of line-wrap rendering, make sure the data has enough CRs in it and then set the field's dontWrap to true.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Max capacity of a field

Post by dunbarx » Fri Sep 11, 2020 3:10 am

Bernd.

There is indeed a published limit to the number of chars in one line in a field: 64K.

But I loaded many more into one line, even with my smallest repeat value. That limit seems not to be valid.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Max capacity of a field

Post by FourthWorld » Fri Sep 11, 2020 4:14 am

Try sorting with that.

The internal structure will let you do some things with longer lines, but not others.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Max capacity of a field

Post by dunbarx » Fri Sep 11, 2020 4:29 am

Richard.

I get all this, and do not want to promote too much esoterica. Its late.

Except for this, how would one sort the chars of a field without fooling around with the string?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Max capacity of a field

Post by FourthWorld » Fri Sep 11, 2020 8:41 am

dunbarx wrote:
Fri Sep 11, 2020 4:29 am
Richard.

I get all this, and do not want to promote too much esoterica. Its late.

Except for this, how would one sort the chars of a field without fooling around with the string?
It must be late, as I don't understand the question. The point of sorting is exactly to fool around with the string.

Let's get some rest and I'll read your reply with a fresh cup of coffee in the morning. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Max capacity of a field

Post by dunbarx » Fri Sep 11, 2020 2:14 pm

Richard.

Its early. Just as bad

I was, er, fooling around with the string, in that one cannot sort the characters of a string. I have had to do this in the past, and have had to:

Code: Select all

loop through each char in the string
append either a space or comma so I could sort by a permitted delimiter
delete the delimiter
I often wondered why the "sort container" command did not allow characters to be sorted directly.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Max capacity of a field

Post by FourthWorld » Fri Sep 11, 2020 9:33 pm

I'm not exactly sure what that last code block should do, but in the original just use "123456789 " instead of "1234567890" in your temp var and you'll have lots of spaces reasonably matching what one would expect to find in real-world text.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Max capacity of a field

Post by dunbarx » Sat Sep 12, 2020 2:50 am

Richard.

If you have spaces, you have a "delimiter" with which to sort. My original fooling around had none. The line:

Code: Select all

delete the delimiter
was pseudoCode, er, very, very pseudo like the other two. I meant something like:

Code: Select all

repeat for each char tChar in tRunOnStringOfNumbers
put tChar & comma after accum
sort items of accum numeric
replace comma with empty in accum
Because there is no "sort chars" in LC.

Craig

Post Reply