Button Menu & Database Builder

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Chris_Wood
Posts: 11
Joined: Sun Jan 06, 2008 1:22 am

Button Menu & Database Builder

Post by Chris_Wood » Wed Aug 27, 2008 7:28 am

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Wed Aug 27, 2008 10:47 am

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:

Code: Select all

edit script of card "revdatabaselinkedmenu" of stack "revtemplatepalette"
And change line 28 from:

Code: Select all

disable button "cRevDatabase[menuqueryobject]"
to:

Code: Select all

enable button "cRevDatabase[menuqueryobject]"
Finally, again in the message box:

Code: Select all

save stack "revtemplatepalette"
Best regards,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Chris_Wood
Posts: 11
Joined: Sun Jan 06, 2008 1:22 am

Button Menu & database Builder

Post by Chris_Wood » Wed Aug 27, 2008 10:57 am

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

Chris_Wood
Posts: 11
Joined: Sun Jan 06, 2008 1:22 am

Button menu & database Builder

Post by Chris_Wood » Thu Aug 28, 2008 1:17 am

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Thu Aug 28, 2008 4:22 am

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:

Code: Select all

put tQueryObjects into button "cREVDatabase[queryobject]"
into

Code: Select all

put tQueryObjects into button "cREVDatabase[queryobject]"
put tQueryObjects into button "cREVDatabase[menuqueryobject]"
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Chris_Wood
Posts: 11
Joined: Sun Jan 06, 2008 1:22 am

Button Menu & database Builder

Post by Chris_Wood » Thu Aug 28, 2008 6:36 am

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

jkrische
Posts: 16
Joined: Mon Oct 06, 2008 5:45 pm

Nope, still broken in 3.5

Post by jkrische » Sat May 16, 2009 8:00 am

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?

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Sat May 16, 2009 5:26 pm

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

jkrische
Posts: 16
Joined: Mon Oct 06, 2008 5:45 pm

Thanks, but...

Post by jkrische » Sat May 16, 2009 7:13 pm

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:

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
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.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Sun May 17, 2009 7:15 am

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.

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
This will get executed when the user clicks on the menu button but before its content is displayed on screen.

HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”