Page 1 of 1

set the dgText is occasionally acting like EXIT

Posted: Sat Jun 18, 2011 9:48 pm
by campsoftware
We're new to LiveCode. In fact, we just started with it last week! We're coming from a background using FileMaker and also RealBasic.

The problem is that when 'set the dgText' runs it's like occasionally stops the script. We're calling the command below from the Stack script. On openStack we're opening/creating a database and then calling the command userGridUpdate, then we go to the Home card to view the grid of users. The database is bring created successfully and there is a record in the table. The grid has two columns where the userID is hidden and the username is visible.

If I manually go to the Home card, the Message Box appears with this:

Code: Select all

89,8775,50,dgAlternatingRows
77,8775,50
456,8775,38
380,8775,9
572,8775,1
253,8759,1
241,8759,1,_DrawAlternatingRows
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/LiveCode 4.6.1.app/Contents/Tools/Toolset/revdatagridlibrary.rev"
573,87,1
253,86,1
This is the command that is stopping 'set the dgText'

Code: Select all

command userGridUpdate
   ## Create tab delimited data.
 Note that first line has name of columns.
 Providing names tells Data Grid how to map
 data to appropriate columns. 
    
   if databaseID = -1 then exit to top
   put revDataFromQuery( tab, return, databaseID, "SELECT IDuser, name from users") into userRecords
   put "IDuser" & tab & "Name" & cr before userRecords   
   answer information "About to set the Grid: " & cr & userRecords
   set the dgText [ true ] of group "userGrid" on Card "Home" to userRecords
  // true is for 'first line has column names'
   answer information "Grid is set."
end userGridUpdate
Thanks for any assistance!
Hal Gumbert, CampSoftware

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 4:02 pm
by Klaus
Hi Hal,

you mean the scripts exits (sometimes) at this point:
command userGridUpdate

Code: Select all

  ## Create tab delimited data.
 Note that first line has name of columns.
 Providing names tells Data Grid how to map
 data to appropriate columns. 
    
   if databaseID = -1 then exit to top
   put revDataFromQuery( tab, return, databaseID, "SELECT IDuser, name from users") into userRecords
   put "IDuser" & tab & "Name" & cr before userRecords   
   answer information "About to set the Grid: " & cr & userRecords
  ...
?
So you see the dialog with the database records?
Hm, should always work!?

A tiny thing:
...
set the dgText [ true ] of group "userGrid" OF Card "Home" to userRecords
## not ON card "Home"
...

And maybe you should add the stack, too:
...
set the dgText [ true ] of group "userGrid" OF Card "Home" OF STACK "your stack here" to userRecords
...

Just guessing, no concrete idea...


Best

Klaus

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 4:13 pm
by campsoftware
Thanks Klaus. I'll try adding the OF STACK and report back.

I always see: answer information "About to set the Grid: " & cr & userRecords

Sometime the script continues and I see: answer information "Grid is set."

When ever it stops on the "set the dgText", I don't see the 'Grid is Set.' and it doesn't return back to the openStack code...

Thanks, Hal

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 5:24 pm
by Klaus
Hi Hal,

maybe your database stuff does not work?

Add this:
...
put revDataFromQuery( tab, return, databaseID, "SELECT IDuser, name from users") into userRecords
IF the result <> empty Then
answer the result
endif
## Maybe this will give a clue?
...


Best

Klaus

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 5:34 pm
by campsoftware
Thanks again Klaus!

I added the 'of stack' and that didn't make it work.

The database seems OK. The variable userRecords contains:
IDuser Name
1 Hal
2 Alex
The data grid is named "userGrid" and I have two columns defined: IDuser and Name

I have a feeling that the "revdatagridlibrary.rev" library isn't loading. I'm not sure how to tell if it's loaded or how to force load it...

Thanks, Hal

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 6:17 pm
by campsoftware
So, I just created a new stack with a Grid, and ran this code.

Code: Select all

put "IDuser" & tab & "Name" & cr & "1" & tab & "Hal" into userRecords   
answer information "About to set the Grid." & cr & userRecords
set the dgText [ true ] of group "userGrid" on card "Home" to userRecords // true is for 'first line has column names'
answer information "Grid is set."
The new stack worked perfectly. So I went back to the stack that I've been working on. I tried to delete the Grid, but it would not go away so I ungrouped it and deleted the parts. Then I pasted the grid from the new stack and it worked. So, I saved, quit, and reopened the stack. It worked again. Once again, I quit and reopened. This time is wouldn't run. I click a button that calls openStack and it then ran...

Is this normal? Is Data Grid buggy? Could my Stack be corrupt?

I also noticed my column names went blank as show below. Should that happen?

Re: set the dgText is occasionally acting like EXIT

Posted: Sun Jun 19, 2011 6:23 pm
by campsoftware
I was thinking about the grid not loading. So, I changed my On openStack script to go to the Home card and then to my Splash card. The idea was to go to the card so the object loads. This now works fine after quitting LiveCode and opening the stack several times. The column names are appearing properly now too.

Does this mean that I should go to cards before accessing the objects on the card?

Thanks, Hal