Tip: How To Start A Browse With The Last-Used QBE Query

By Randy Rogers

Posted June 19 2001

Printer-friendly version

I recently added Query By Example (QBE) to a browse and was pleased with the ease of implementing this functionality. I wanted my application to open the browse using the most recently used query (the default is to open the browse without any QBE filters). After a lot of experimenting, I was able to accomplish what I needed with two strategically placed lines of code.

Here's how to have a browse start with the most recent QBE query. In the WindowManager.Init Method [8505] (after process field templates) embed I added the following code:

BRW1.Query.Restore('tsMRU')

In the Browse on filename using ?Browse:1 (Browse Class) ApplyFilter Method [4500] (before parent call) I placed this code:

SELF.SetFilter(SELF.Query.GetFilter(),'9 - QBE')

That's all there is to it. Calling the Restore method with 'tsMRU' causes the QueryClass to fill its FieldQueue with the tsMRU section of the program's INI file. This is a queue of the field contents for the most recently used query (hence the acronym MRU). Other saved queries are stored in the INI file too! GetFilter returns a properly constructed filter expression based on the contents of the FieldQueue which I loaded earlier with Restore.

The SetFilter method appends the query filter to any existing filters because I specify the '9 - QBE' id, which is used by the templates. See the ViewManager SetFilter method help for details.

Randy Rogers is a data processing professional with over 35 years of experience in a wide variety of industries including accounting, municipal government, insurance, printing, and pharmacoeconomics. He has a degree in Mathematics from Florida State University and is the president of Keystone Computer Resources. Randy is the author of ClassViewer, a utility for browsing the Clarion class hierarchies. He is also the creator of NetTools, Queue Edit-in-Place, and Screen Capture Tools for Clarion application developers.

Clarion Roadmap

Try the roadmap (beta)

Search ClarionMag

 

Advanced search

From the archives

The Best Thing About Clarion 7

12/27/2010 12:00:00 AM

Steve Parker was just plain gobsmacked when he realized he had found something in C7 that improved his code and did so with virtually no effort on his part.