Page 1 of 1

datagrid problem..

Posted: Wed May 06, 2020 9:12 pm
by rbeynon
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

Re: datagrid problem..

Posted: Wed May 06, 2020 9:44 pm
by Klaus
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

Re: datagrid problem..

Posted: Wed May 06, 2020 9:52 pm
by rbeynon
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?

Re: datagrid problem..

Posted: Wed May 06, 2020 9:54 pm
by rbeynon
p.s. menu item and datagrid are in the same stack, on the same card

Re: datagrid problem..

Posted: Wed May 06, 2020 9:57 pm
by Klaus
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

Re: datagrid problem..

Posted: Wed May 06, 2020 10:00 pm
by rbeynon
will do - check your mail box

Re: datagrid problem..

Posted: Wed May 06, 2020 10:21 pm
by Klaus
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!

Re: datagrid problem..

Posted: Thu May 07, 2020 2:47 am
by rbeynon
296kb!
Weird? Did I send you my hard disk? 😂

Re: datagrid problem..

Posted: Thu May 07, 2020 8:09 am
by rbeynon
further curious observation.. exactly the sme code worked, and still works, in a previous version of this stack. It's all very odd!

Re: datagrid problem..

Posted: Thu May 07, 2020 8:50 am
by rbeynon
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..??

Re: datagrid problem..

Posted: Thu May 07, 2020 9:45 am
by Klaus
Rob, please check your mails, something went wrong with the attachment.
OK, finally got it, will take a look now...

Re: datagrid problem..

Posted: Thu May 07, 2020 10:29 am
by Klaus
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!

Re: datagrid problem..

Posted: Thu May 07, 2020 7:05 pm
by rbeynon
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?