Button Menu & Database Builder
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 11
- Joined: Sun Jan 06, 2008 1:22 am
Button Menu & Database Builder
I have a query built with the Query Builder & SQLite which returns a single column. The query works fine as it displays the results in a table.
What doesn't seem to work is putting the same result into a button pull down menu. Under the database properties, the menu items group is disabled. How does one fill a button menu with a query result? The interface does imply it can be done without coding.
Many Thanks
Chris
What doesn't seem to work is putting the same result into a button pull down menu. Under the database properties, the menu items group is disabled. How does one fill a button menu with a query result? The interface does imply it can be done without coding.
Many Thanks
Chris
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Hi Chris,
You should indeed be able to pick a query to fill the menuitems. This looks like a bug in the Inspector palette, which always disables it. I just went to the Quality Center and found this report: http://quality.runrev.com/qacenter/show_bug.cgi?id=4666 - though it seems this was never fixed, as it is still present in version 3.0.0-rc-2
Sorry to disappoint you.
WARNING - not for the faint-hearted:
If you feel particularly adventurous, you can fix this yourself in the inspector palette code. First make a backup copy of your Revolution installation, and then execute the following in the message box:
And change line 28 from:
to:
Finally, again in the message box:
Best regards,
Jan Schenkel.
You should indeed be able to pick a query to fill the menuitems. This looks like a bug in the Inspector palette, which always disables it. I just went to the Quality Center and found this report: http://quality.runrev.com/qacenter/show_bug.cgi?id=4666 - though it seems this was never fixed, as it is still present in version 3.0.0-rc-2
Sorry to disappoint you.
WARNING - not for the faint-hearted:
If you feel particularly adventurous, you can fix this yourself in the inspector palette code. First make a backup copy of your Revolution installation, and then execute the following in the message box:
Code: Select all
edit script of card "revdatabaselinkedmenu" of stack "revtemplatepalette"
Code: Select all
disable button "cRevDatabase[menuqueryobject]"
Code: Select all
enable button "cRevDatabase[menuqueryobject]"
Code: Select all
save stack "revtemplatepalette"
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 11
- Joined: Sun Jan 06, 2008 1:22 am
Button Menu & database Builder
Thanks Jan you really know your stuff, I'll give your fix a tryout. Hopefully it will be put right in the next release.
Best Regards
Chris
Best Regards
Chris
-
- Posts: 11
- Joined: Sun Jan 06, 2008 1:22 am
Button menu & database Builder
Dear Jan,
Tried your fix last night and it enabled the menu items area as you said but there aren't any options in the query menu except 'None'
Obviously this goes deeper than first thought. Since this issue was noted under v2.8 perhaps another bug report is due. I'll send one in.
Best Regards
Chris
Tried your fix last night and it enabled the menu items area as you said but there aren't any options in the query menu except 'None'
Obviously this goes deeper than first thought. Since this issue was noted under v2.8 perhaps another bug report is due. I'll send one in.
Best Regards
Chris
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Hi Chris,
Thanks for informing me it wasn't enough. Fortunately, this is another easy fix - follow the same steps as earlier, but insert another line after line 22 to fill the menu. So turn:
into
Hope this helped,
Jan Schenkel.
Thanks for informing me it wasn't enough. Fortunately, this is another easy fix - follow the same steps as earlier, but insert another line after line 22 to fill the menu. So turn:
Code: Select all
put tQueryObjects into button "cREVDatabase[queryobject]"
Code: Select all
put tQueryObjects into button "cREVDatabase[queryobject]"
put tQueryObjects into button "cREVDatabase[menuqueryobject]"
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 11
- Joined: Sun Jan 06, 2008 1:22 am
Button Menu & database Builder
Hi Jan,
That appears to have done the trick. Many thanks
If its so easy to correct it doesn't make a lot of sense that this has remained uncorrected for such a long time. Lets hope one of the programmers picks up on it.
Best Regards
Chris
That appears to have done the trick. Many thanks
If its so easy to correct it doesn't make a lot of sense that this has remained uncorrected for such a long time. Lets hope one of the programmers picks up on it.
Best Regards
Chris
Nope, still broken in 3.5
Just confirming that this is still broken in 3.5, will be talking to QA about it soon enough.
Glad to have found Jan's fixes, have been going around and around with ONE SIMPLE, STUPID LITTLE OPTION BUTTON for 5 hours now!! Jan's fixes at least made the Menu Items bits of the Database section available for picking things, so many thanks, Jan.
But, to also note: the fixes don't seem to work for me. That is, the menu button inspector allows me to now pick things in the Menu Items section of the Database properties of that button, but those selections don't seem to actually DO anything. I pick the query, I pick the column, all seems well. But, when I go to make use of that button, I am still stuck with a menu of "Choice 1 | Choice 2 | Choice 3", ie, the default values for a new object, instead of the field values I picked in the Inspector.
Either I am missing something important or there is a pretty glaring bug here. Any ideas?
Glad to have found Jan's fixes, have been going around and around with ONE SIMPLE, STUPID LITTLE OPTION BUTTON for 5 hours now!! Jan's fixes at least made the Menu Items bits of the Database section available for picking things, so many thanks, Jan.
But, to also note: the fixes don't seem to work for me. That is, the menu button inspector allows me to now pick things in the Menu Items section of the Database properties of that button, but those selections don't seem to actually DO anything. I pick the query, I pick the column, all seems well. But, when I go to make use of that button, I am still stuck with a menu of "Choice 1 | Choice 2 | Choice 3", ie, the default values for a new object, instead of the field values I picked in the Inspector.
Either I am missing something important or there is a pretty glaring bug here. Any ideas?
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Go back to the Database query builder and hit the 'Refresh query' button in the 'Record set' tab - that should refresh the contents of your option menu.
HTH,
Jan Schenkel.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Thanks, but...
Hi Jan...
Again, thanks for your help. It worked, kinda. As I expected, this gets the *initial* population of the button to have DB values, but when the DB entries change, the button should change, too, without me having to go in to Query Builder and hit the Refresh.
I assume I'm going to need to do some scripting for this... so, what's the general way one would do this? Here's what I have so far:
1. in stack script, an on openStack section which connects to the DB and puts the connection ID into a global variable myGConID
2. in the button script (the button's name is "currentpat"), an on mousedown handler as follows:
This makes sense to me, but it doesn't work. I get a revdberror "SQL error or missing database". Well, that SQL is as simple as it gets, no errors there, and if I insert an "answer myGConID" after the global call, I get the right connection ID, so I am stumped. The db file is indeed there and populated, so I am getting really confused by this error.
Again, thanks for your help. It worked, kinda. As I expected, this gets the *initial* population of the button to have DB values, but when the DB entries change, the button should change, too, without me having to go in to Query Builder and hit the Refresh.
I assume I'm going to need to do some scripting for this... so, what's the general way one would do this? Here's what I have so far:
1. in stack script, an on openStack section which connects to the DB and puts the connection ID into a global variable myGConID
2. in the button script (the button's name is "currentpat"), an on mousedown handler as follows:
Code: Select all
on mouseDown
global myGConID
// get all the patient IDs
put "SELECT patID FROM patient_data ORDER BY patID ASC" into tSQL
put revdb_querylist(,,myGConID,tSQL) into tList
put tList into me
end mouseDown
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
The problem you're facing is a typical problem for database client applications: the query you've executed returns the data contents of the time of the query but doesn't get automatically updated when something in the database changes.
Environments like FileMaker shield the developer from this problem, and use an internal messaging system to warn all clients that something has changed and that they should refresh their screen accordingly. But FileMaker can only do that because it controls every layer of the environment from client to server.
If you build a Rev front-end to a FileMaker database, then any FM clients will automatically update, but your Rev client isn't going to get a heads-up. An integrated package can offer you a lot of power, but means you can't switch databases all that easily - the more "unique" features you use, the more you are locked into the product.
Anyway, you can re-use the existing database connection using the revConnectionOfQuery function.
This will get executed when the user clicks on the menu button but before its content is displayed on screen.
HTH,
Jan Schenkel.
Environments like FileMaker shield the developer from this problem, and use an internal messaging system to warn all clients that something has changed and that they should refresh their screen accordingly. But FileMaker can only do that because it controls every layer of the environment from client to server.
If you build a Rev front-end to a FileMaker database, then any FM clients will automatically update, but your Rev client isn't going to get a heads-up. An integrated package can offer you a lot of power, but means you can't switch databases all that easily - the more "unique" features you use, the more you are locked into the product.
Anyway, you can re-use the existing database connection using the revConnectionOfQuery function.
Code: Select all
on mouseDown
put revConnectionOfQuery("AllCustomers") into tConnectionId
put "SELECT cust_Name FROM Customer" into tQuery
put revDataFromQuery(,,tConnectionId,tQuery) into me
end mouseDown
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com