datagrid problem..

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

datagrid problem..

Post by rbeynon » Wed May 06, 2020 9:12 pm

Good day all - rank amateur here..

I have a datagrid table, and this script extracts the data to a variable pepList.
All well and good, but the problem I have is that this code works from a button, but doesn't work from a menu item, in the same application. I have pasted, verbatim, the code from a button to another button (works) or to the menu item (fails)

I can't find an issue with, say, a global vs local variable, and even the temporary answer at the end delivers an empty, tab delimited, pepList file.

What am I missing, please?

Many thanks
Rob

Code: Select all

-- now recover the data from the data grid
         put the dgData of group "peptideTable" into theDataA
         -- Get indices of table in proper order
         put the dgIndexes of group "peptideTable" into theIndexes
         -- clear variable
         put empty into pepList
         -- Loop through data, putting into a variable in tab delim format
         REPEAT for each item theIndex in theIndexes
            put theDataA[theIndex]["pep"] & tab after pepList -- first word
            put theDataA[theIndex]["M"] & tab after pepList
            put theDataA[theIndex]["[M+H]+"] & tab after pepList
            put theDataA[theIndex]["[M+2H]++"] & tab after pepList
            put theDataA[theIndex]["Sequence"] & tab after pepList
            put theDataA[theIndex]["Annotation"] & tab after pepList --sixth word
            put theDataA[theIndex]["Unused"] & return after pepList -- seventh word
         END REPEAT-- now have a tab delim variable (pepList) containing all info
         answer pepList

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid problem..

Post by Klaus » Wed May 06, 2020 9:44 pm

Hi Rob,

since the script works in a button, it will be definitvely OK!
I guess that the script in the menuitem, which is probably in another stack?, does not find the datagrid.

Try this, add the name of the stack with the datagrid in it as the defaultstack in the first line of the script:

Code: Select all

...
## This one:
set the defaultstack to "name of the stack with the datagrid in it here"
##

-- now recover the data from the data grid
put the dgData of group "peptideTable" into theDataA
-- Get indices of table in proper order
put the dgIndexes of group "peptideTable" into theIndexes
...
Should do the trick, please try and report back.

Best

Klaus

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Wed May 06, 2020 9:52 pm

Thank you Klaus..
I tried your suggestion, no joy

Then, from within the menu script, I put a line in
answer theIndexes

and the indicate are correct. So, I surmise that the menu can 'see' the data grid, but cannot pull the contents..
yes the script works fine outside of the menu

Real;ly annoyingly, this was working earlier today, but at some point, I wa asked to save as an LC8 rather than an LC7 app... I wonder if it broke then?

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Wed May 06, 2020 9:54 pm

p.s. menu item and datagrid are in the same stack, on the same card

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid problem..

Post by Klaus » Wed May 06, 2020 9:57 pm

Hi Rob,

very strange!? :shock:

I could offer to take a look at your stack.
Put it online somewhere and send me the link or just mail me the stack, if you like -> klaus AT major-k.de


Best

Klaus

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Wed May 06, 2020 10:00 pm

will do - check your mail box

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid problem..

Post by Klaus » Wed May 06, 2020 10:21 pm

I'm doing!

How big is the stack? Takes ages to load and is currently at 5.1 MB and counting... 8)
Currently at 8.9 MB and no end in sight.

Hint for the future:
Everything over 5 MB should not be sent via mail!

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Thu May 07, 2020 2:47 am

296kb!
Weird? Did I send you my hard disk? 😂

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Thu May 07, 2020 8:09 am

further curious observation.. exactly the sme code worked, and still works, in a previous version of this stack. It's all very odd!

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Thu May 07, 2020 8:50 am

And, even curiouser. I can send a mouseUp message to an invisible button on the main card that does the extraction, puts the data into a field, and then put the contents of that hidden field where I want it. It's as if the menu script cannot 'see' the grid, all of a sudden...
no, that's not true, the menu script can recover the indices just fine. It's the data it is struggling with..??

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid problem..

Post by Klaus » Thu May 07, 2020 9:45 am

Rob, please check your mails, something went wrong with the attachment.
OK, finally got it, will take a look now...

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: datagrid problem..

Post by Klaus » Thu May 07, 2020 10:29 am

OK, I took some deeper looks and it seems the stack is definitively CURSED!
This line:

Code: Select all

...
put the dgdata of grp "the datagrid here" into theDataA
...
Works in a button but NOT in a menuitem on the same card!
I tried with other variables, IT and whatnot, no dice!?

Even stranger: This line

Code: Select all

...
put the dgindexes of grp "the datagrid here" into tIndexes
...
Works in the button AND in the menuitem.
So both scripts have these lines:

Code: Select all

...
put the dgindexes of grp "the datagrid here" into tIndexes
put the dgdata of grp "the datagrid here" into theDataA
## Yes, they are contiguous lines in the same script!
## Swapping the lines has no effect!?
...
tIndexes gets filled correctly but theDataA stays EMPTY no matter what I tried!?

Any hints appreciated!

rbeynon
Posts: 15
Joined: Fri Sep 21, 2007 7:07 am

Re: datagrid problem..

Post by rbeynon » Thu May 07, 2020 7:05 pm

First: shout out to Klaus who took the time...
Second: I am mostly relieved that this is not a silly beginner error. Could there be a bug?

Post Reply