ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· º º º 01 JUN 93 CDFILTER 22:00:00 º º º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º º º Jose CONSTANT º º º º Copyright (c) 1993 Constant Sofware Systems º º Rue de la chˆnaie, 7 º º 4650 Chaineux (Herve) º º Belgium. º º Phone: +32 (0)87-679-178 º º Fax: +32 (0)87-674-189 º º CompuServe: 100010,752 º ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ ***CONTENTS*** The following files are provided as a convenience to members of the FoxForum on CompuServe: CDFILTER.SCX CDFILTER.SCT FILTLIBR.DBF JCBROWSE.SCX JCBROWSE.SCT README.TXT && This file **************************************************************************** ***INSTALLATION*** To install, copy the content to the apropriate directory and PkUnZip CDFILT.ZIP. CDFILTER should work with any FoxPro 2.0 flavour. This is a reusable piece of code, so you probably will want to install it in your ..COMMON\SCREENS directory **************************************************************************** ***CODEBOOK USERS*** The idea behind these two screens is to provide our users with an easy yet powerfull way to filter their data, either on screen (what they will see displayed in their windows) or in their lists, reports and labels. Some of you will find this unnecessary, others will find this quite usefull. Much depends of the app. One I am working on is a CAR DEALERSHIP. The users are delighted to be able to Browse and report their Data per Make, per status (Is this car paid or under consignation?) etc... To see CdFilter at work, just do the following: Add a prompt under the DataBase menu pad: Filter... that calls a Procedure: DO Cdfilter.spr (or Cdfilter.prg if you save it this way) GO TOP && moves record pointer SCATTER MEMVAR MEMO DO DIMNAVIGAT [X]SKIP FOR SEEK("Datafilt","Security").OR. LEN(WONTOP())=0 Copy filtlibr.dbf and filtlibr.fpt to your working directory (Cdfilter will open/close this table when necessary. You might want to change this, and open it for once in your OpenDbf routine). CDFILTER Sets filter to an expression as explained in plain English for the record choosen from the list. Remove a filter that was set previously Build a new filter expression (calls JcBrowse) Delete a filter expression from the filtlibr table Closes this window JCBROWSE This little utility uses the BROWSER that Fox provided us with 2.0 and adds the required code to handle the DATADICT when it is there. The purpose is to give our users a friendlier way to build their queries by giving them a full description of the fields they are playing with, or they use as index. For this I rely on the Ctag field in the DATADICT.DBF. I test for ! EMPTY(ctag). So you can easily decide with which fields you'll let them play. The ones for which you'll let ctag empty will be unavailable to the users. Once the query is build up, it. If it works like you planned, enter the English description of the filter in the lcFiltname Field name and save it! To understand better how the original Browser works, you might want to download BROWSE.DOC, a very good explanation by Tom Lewinson, 70461,151. LET'S GO A LITTLE FURTHER It is easy to provide the users with a visual clue that a filter has been set by adding a say field to every window subject to be filtered: IIF(EMPTY(FILTER()),"","Filter!") It is also important to SET FILTER TO when the user closes the window. So in every cleanup code of every screen set subject to be filtered: IF glQuitting ... RELEASE WINDOW Wr..... IF ! EMPTY(FILTER()) SET FILTER TO ENDIF DO efface ENDIF I declare the GcFiltrexpr variable as public in the setup code of CdFilter so that when a filter is set and you want to run a list or a report, you could place in the header: IIF(EMPTY(FILTER()),"",ALLTRIM(gcfiltrexpr)) Your output would tell in plain English which filter was set. You can even use the filter expression in a query (in Codebook Reports as opposed to lists). Here is how you should do: *STOCKVN1.QPR PRIVATE lcCond IF EMPTY(FILTER("stockvn")) && Is there a filter set for the StockVn table? lcCond = "" ELSE lcCond = "HAVING "+ALLTRIM((FILTER("STOCKVN"))) ENDIF * Then make you sql Select SELECT * ; FROM stockvn ; &lccond ; WHERE ..... ; INTO CURSOR stockvn1 SET ENJOY ON *************************************************************************** USE RESTRICTIONS You may use CDFILTER and modifications thereof as part of your applications without prior authorization from Constant Software Systems and without payment to Constant Software Systems. CDFILTER may be freely distributed on electronic BBSes and via non-profit user group disk libraries. CDFILTER and modifications thereof may *NOT* be sold as shareware or as a commercial product. Use of the CDFILTER routine and modifications thereof in articles and books is reserved solely to Constant Software Systems. Please, send me your feedback! Jose CONSTANT 100010,752 *************************************************************************** ***CHANGES.LOG*** 27/03/93 Since the 1st version uploaded on CompuServe on 22/03/93, the following changes have been made in CDFILTER.SCX Procedure Controlprc CASE m.lchcoice="Supprime" && delete IF DELREC() SELECT filtlibr ==> LOCATE FOR filtname=lafilter(lnfilter,1) ... (otherwise you would delete just any filter...) SCREEN SHOW As first line, add: LaFilter(1,1)="" && So when you have only one item in LaFilter and you delete it, the LaFilter will be completely blank. 01 JUN 93 Since the 2nd version uploaded on CompuServe on 27/03/93, the following changes have been made. 2.5 DOS CDFILTER.SCX CLEANUP CODE CASE m.lcchoice = "Supprime" && delete IF DELREC() SELECT filtlibr LOCATE FOR filtname=lafilter(lnfilter,1) && new 01 JUN 93 *LOCATE FOR filtname=lafilter(lnfilter,1)&& old DELETE IF .NOT. EOF() SKIP ELSE GO BOTTOM ENDIF SELECT (lcSaveArea) SHOW GETS && refreshes array ENDIF CASE m.lcchoice = "Pose" && Set lcfiltname = lafilter[lnfilter,1] *lcfiltexpr = filtlibr.filtexpr && old lcfiltexpr=lafilter[lnfilter,2] && new 01 JUN 93 PRIVATE lncount COUNT FOR &lcfiltexpr TO lncount IF lncount = 0 WAIT WINDOW NOWAIT "No record meets this condition!" ELSE WAIT WINDOW NOWAIT "filter is set!" SET FILTER TO &lcfiltexpr llfilter = .T. *gcfiltrexpr=filtlibr.filtname && old gcfiltrexpr=ALLTRIM(lafilter(lnfilter,1)) && new 01 JUN 93 SELECT filtlibr USE SELECT (lcSaveArea) CLEAR READ ENDIF *** JCBROWSE is the son of CDBROWSE, that I posted as CDBROW.ZIP in Lib 10 on january 4 and that scored at 129 in less than 6 weeks. //05 JAN 93: IMPROVEMENT To make the "GETORDER" screen work properly, just change the condition in the SQL SELECT in SETUP CODE from ./. AND ! EMPTY(datadict.Ctag) && old code ./. into ./. AND lindex && new code See the explanation above: I use Ctag to decide whether or not let the user filter this field. So this might result in Getorder trying to set Index to something that's not in the index. Testing for lindex makes the trick effortless! //25 JAN 93: BUG memo field was not adressed properly. Here is a fragment of the AD Valid snippet CASE typ = "C" or typ = "M" && I forgot "or typ = "M" " y = brackets(y,"'","'") CASE typ = "D" y = brackets(y,"{","}") ENDCASE **************************************************************************** ***THE USUAL COMPUTER SOFTWARE STATEMENTS*** THIS ZIPPED FILE AND THE FILES IT CONTAINS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE FILES RESTS WITH YOU. CONSTANT SOFTWARE SYSTEMS DOES NOT WARRANT THAT THE CONTENTS OF THIS ZIPPED FILE WILL MEET YOUR REQUIRMENTS OR BE FREE OF ERRORS. IN NO EVENT SHALL CONSTANT SOFTWARE SYSTEMS BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING LOST PROFITS, LOST SAVINGS, CONSEQUENTIAL, SPECIAL, INCIDENTAL OR INDIRECT DAMAGES OF ANY KIND ARISING OUT OF THE USE OF OR INABILITY TO USE THIS DISKETTE, ITS CONTENTS, OR ANY INFORMATION PROVIDED BY CONSTANT SOFTWARE SYSTEMS, EVEN IF CONSTANT SOFTWARE SYSTEMS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOU ACKNOWLEDGE THAT YOU HAVE READ THIS AGREEMENT, UNDERSTAND IT AND AGREE TO BE BOUND BY ITS TERMS AND CONDITIONS. YOU AGREE THAT THIS IS THE ENTIRE AGREEMENT BETWEEN YOU AND CONSTANT SOFTWARE SYSTEMS. IT SUPERSEDES ANY PRIOR AGREEMENT, WHETHER WRITTEN OR ORAL, RELATING TO THE SUBJECT OF THIS AGREEMENT. EOF()********************************************************************