DataGrid2 - What do you like, what don't you like

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Tue Oct 26, 2021 8:43 pm

RCozens wrote:
Tue Oct 26, 2021 8:29 pm
An argument name in the Dictionary is not a literal or a reserved word, Dick.
My apologies, Dick.

I see your reference in the Dictionary. The difference is "startTime" in the Dictionary is a property, whereas "startTime" in my handler is a variable. One sets the value of a property whereas one puts a value into a variable. Also, a property is not reserved: EG. Width, Text, backgroundColor, etc.

None of this explains why Stam's Mac chokes on my use of "startTime"; but I have not tried to compile the stack. I see Serendipity Editors as an extension of the LiveCode IDE, not a standalone app.

Cheers!
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Tue Oct 26, 2021 9:05 pm

stam wrote:
Mon Oct 25, 2021 12:52 am
Regarding busy cursor: Yes you can! Just use the spinner widget. Show it before starting your operation and hide it when done. It will spin ;)
Perhaps we're looking at another Win32 vs MacOS difference? Though I can see another issue...

This handler will not spin the spinner:

Code: Select all

on hideOutput -- 26 Oct 21:RCC
   set the disabled of button "Hide Output" to true
   set the visible of group "Output Group" to false
   set the visible of control "Spinner" to true
   put the ticks into myStartTime
   wait 0 with messages
   set the dgText of group "Image Pixel Display" to empty
   set the visible of control "Spinner" to false
   put the ticks - myStartTime
   showImages
   send ("resetButtons"&&(the number of images)) to group "Image Editor Controls"
   set cursor to arrow
end hideOutput
If I don't hide the spinner right after I set the dgText it does spin.

From LiveCode Dictionary Guide:
The spinner widget will only update (rotate to its next notch) when the engine gets to do event processing, such as during a wait with messages statement
The examples show "wait 0 with messages" inside a repeat loop. There is no repeat loop in my handler.

I can't see any way to show busy status or progress during the time LiveCode is setting dgText unless LiveCode builds it into the dataGrid object.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: DataGrid2 - What do you like, what don't you like

Post by stam » Tue Oct 26, 2021 9:24 pm

RCozens wrote:
Tue Oct 26, 2021 9:05 pm
The examples show "wait 0 with messages" inside a repeat loop. There is no repeat loop in my handler.
I don't use the spinner within a loop either - i use this during a blocking operation with LiveCloud (the 'login procedure' is about 4 seconds long, so this updates the user face).
I just:
1. show the widget
2. do the operation
3. hide the widget
No loop involved... and normally this works well.

Now in your case it doesn't work - but then again have you even tried to review the text content of your data grid? it takes like 20-30 seconds to load in the viewer. I think it's the sheer size of the text that is bringing LC to it's knees a bit there.

I have no way of knowing if it's more efficient, but have you considered storing the data in an array rather than text, and assigning that array to the dgData of the data grid?

Might be much more efficient. And easier to query.

I'm abroad on some difficult family business, but i'll have a go at that unless someone beats me to it...

Stam

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Tue Oct 26, 2021 9:51 pm

Thank you as always, Stam

Again from the Dictionary Guide:
There are several commands and functions which implicitly wait with messages internally, such as the url chunk.
I can only assume you are using one such command...and suggest "set the dgText ..." should do so also.

The 1100 ticks are calculated here:

Code: Select all

   put the ticks into myStartTime
   set the dgText of group "Image Pixel Display" to fieldOutput
   put the ticks - myStartTime
The progress bar is displayed during the repeat group that reads each pixel's four bytes and alphaData & maskData bytes into a display line, which is placed at the end of the variable, fieldOutput. (Look at the scanImage handler in the script of the Image Editor card.)

I'm waiting for someone else on Windows to report whether they get short delays like you or long delays like moi, though if I were to post an enhancement based on what I think I know now, I would request that the code for the set dgText command implicitly wait with messages internally.

Cheers!
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Tue Oct 26, 2021 11:36 pm

I had to laugh out load! Hope you will too.

In an effort to reduce processing time I decided to test whether logic like this:

Code: Select all

         put byteToNum(byte (byteNumber+3) of imagePixels) into greenValue
         repeat until length(greenValue) = 3
            put "0" before greenValue
         end repeat
would run faster than

Code: Select all

         put byteToNum(byte (byteNumber+3) of imagePixels) into greenValue
         if greenValue < 100 then
            repeat until length(greenValue) = 3
               put "0" before greenValue
            end repeat
         end if
 
The goal is to format each byte to three-character values; so only bytes with values of 99 or less out of a max value of 255 need rendering.

Remember, similar logic is applied to each any every byte in the imageData, alphaData, & maskData; so some small edge in timing applied over something just short of 1.2 billion bytes in this instance could make a difference. So I modified the logic in my test stack, recorded the ticks, added timing logic to the script in my primary development stack, and ran it there.

Turns out the difference in timing was not significant; but low and behold, when I hit "Hide Output", the dataGrid was gone in a flash.

It took me a few minutes of anguish,...wondering what had happened. Then I remembered I had changed my primary stack to delay emptying the dataGrid until closeStack.

The laugh is on me.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Wed Oct 27, 2021 10:30 pm

RCozens wrote:
Tue Oct 26, 2021 9:05 pm
Perhaps we're looking at another Win32 vs MacOS difference?
Turns out it's a stack vs compiled app issue.

In testing today, when uncompiled it takes 1188 ticks to set the dgText representation of the image and 952 ticks to clear it
The compiled version set it in 523 ticks and cleared it in 53.

So that mystery is solved; but the solution uncovers another ignorance on my part: How does one include LiveCode paint tools in a compiled app?

I never intended for Serendipity Editors to be compiled. My concept was another developers' tool, not an app.

Without the paint tools the Image Editor can mask images and create screen snapshots of grouped images; but individual images cannot be created or modified.

Fortunately, the Icon Editor does not use the paint tools; so its functionality is not diminished.

PS: I'm liking the dataGrid a bit more now that I understand the root of my initial disappointment.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: DataGrid2 - What do you like, what don't you like

Post by RCozens » Mon Feb 27, 2023 7:07 pm

RCozens wrote:
Sun Oct 24, 2021 8:21 pm
I am frustrated because all I want the dataGrid to do is display three tab-delimited character strings, each centered in its column.
Morning All,

A year and a half later I finally stumbled upon LiveCode's tabAlign field property. Now I can align individual columns left, centered, or right. It's perfect for my needs and eliminates the overhead associated with dataGrids.

I don't see the need for the latter unless I need to create forms.

Cheers!

Rob
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: DataGrid2 - What do you like, what don't you like

Post by Klaus » Tue Feb 28, 2023 2:51 pm

I very often "abuse" a DataGrid2 object to have a "listfield" where the user can re-arrange the lines by just dragging them.
Very cool feature, which is still missing from the regular "listfield". :-)

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: DataGrid2 - What do you like, what don't you like

Post by stam » Thu Mar 02, 2023 8:04 pm

I'll only add that test this premise broke LC for me.
I'm using a massive data set with > 160,000 records (~160 Mb as a text file) and using a table field as truly brought LC to it's knees on an M2 Air with 24 Gb RAM and > 400 Gb free flash drive storage (for swap file). However adding these to a data grid is a breeze, you'd never know there was a problem...

Clearly the text field is not fit for reviewing/manipulating large data sets - possibly this may improve if/when LC goes 'fully native' for Apple Silicon (not tested on a Windows box, but I suspect may be the same there).

Just my $0.02...
S.

Post Reply

Return to “Talking LiveCode”