SEARCH works very well. In my applications however, I found that I often wanted to search on something other than the first characters of a column and so have added functions to FNSNAP that will search arrays for an instance of the search criteria and build an array of the row numbers that match. I then append a routine to the normal LIST or GRID query that advances the cursor to the next instance by pressing F3. When the last on is reached the F3 cycles back to the first again.
Following is the code that I use (excluding the FNSNAP functions) to display a list or grid and then search (F2 initiates the search, F3 continues it).
00001 MAT HEADERS$(5) !:
LET HEADERS$(1)="Invoice" !:
LET HEADERS$(2)="Date" !:
LET HEADERS$(3)="Unpaid" !:
LET HEADERS$(4)="This run" !:
LET HEADERS$(5)="Balance"
00002 MAT WIDTHS(5) !:
LET WIDTHS(1)=6 !:
LET WIDTHS(2)=10 !:
LET WIDTHS(3)=12 !:
LET WIDTHS(4)=12 !:
LET WIDTHS(5)=12
00003 MAT FORMS$(5) !:
LET FORMS$(1)="c 6" !:
LET FORMS$(2)="fmt(99/99/9999)" !:
LET FORMS$(3)="pic(zzzz,zz#.##-)" !:
LET FORMS$(4)="pic(zzzz,zz#.##-)" !:
LET FORMS$(5)="pic(zzzz,zz#.##-)" !:
! Add P and format specs if needed
00004 LET FNWINROWCOL(0,LROW,LCOL) ! function is in VOL002NEWSCRN.DLL
00005 LET AROWS=0 : LET SROW=4 : LET SCOL=3 !:
LET LCOLS=MIN(LCOL-SROW-2,SUM(MAT WIDTHS)+2) !:
LET LROWS=MIN(LROW-SROW-2,MAX(3,AD+2+AROWS))
(AROWS is additional rows to add to the bottom of the window that is opened to hold the list or grid so that buttons or other information can be added there)
00007 LET LISTSPEC$=FNLISTSPEC$(LISTWIN,SROW,SCOL,LROWS,LCOLS,AROWS,MAT HEADERS$,MAT WIDTHS,MAT FORMS$,"Select Invoice") !:
! add ,GRID$ after "select Invoice" to make a grid where grid$="GRID"
00008 PRINT #LISTWIN, FIELDS LISTSPEC$&",=R" : (MAT ONE$,MAT TWO$,MAT THREE)
00009 MAT SELECT(1)=(0) !:
00010 INPUT #LISTWIN, FIELDS LISTSPEC$&",rowsub,sel ": AX !:
LET FK=FKEY !:
IF FK=201 THEN LET FK=0 !:
! parameters are !:
! GRID cnt,sub,cell !:
! LIST rowsub,rowcnt,cell!:
! cur,sel,all
00011 IF FK=2 THEN
00012 LET SRCHSTR$=FNSRCHCRIT$(STR$(ROUND(LROWS/2,0)),"2",2,LCOLS-4,LISTWIN,"Item to search for") !:
MAT SELECT(1)=(0) !:
! LET FNLISTSRCH(MAT PDINVNR$,SRCHSTR$,MAT SELECT) !:
! LET FNLISTSRCHN(MAT PDPAID,SRCHSTR$,MAT SELECT) !:
! Turn these on to search for stings in matrixes
00013 IF SELECT(1)=0 AND UDIM(SELECT)=1 THEN !:
LET MSGBOX("No matching criterea","Search Results","OK","EXCL") !:
GOTO 10 !:
ELSE !:
LET FF=1 : LET CURFLD(1,SELECT(FF)) : GOTO 10
00014 END IF
00015 IF FK=3 THEN
00016 IF FF<UDIM(MAT SELECT) THEN LET FF+=1 ELSE LET FF=1
00017 LET CURFLD(1,SELECT(FF)) !:
GOTO 10
00018 END IF
00019 IF NOT (FK=0 OR FK=99) THEN GOTO 10
00020 CLOSE #LISTWIN: !:
LET LISTWIN=0
FNLISTSRCH does a case insensitive search of a named character array
FNLISTSRCHN does a case insensitive search of a numeric array by converting each element to a string before searching
All functions referenced are in FNSNAP.dll
In some cases the imbedded search of BR works great, in other cases the “extended” search capability of the FNLISTSRCH functions works great. It’s good to have multiple tools.
George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
From: br_forum-bounces@ads.net [mailto:
br_forum-bounces@ads.net]
On Behalf Of Luis I. Gomez
Sent: Friday, May 22, 2009 7:52 AM
To: Business Rules Forum
Subject: Re: [BR_forum] Search with Grid / List
Nice example!
25790 Input #EMF_WIN, Fields "1,16,SEARCH 30,U,2,1;2,1,LIST 19/59,ROWCNT,SEL" : SEARCH_ARG$,AVAIL_ROWS
I pulled this one line out of the sample. It might not have been obvious with all of that code.
1,16,SEARCH 30,U,2,1
Row,Column,SEARCH ##,Attribute,List Row,List Column.
It’s almost like a “C”, but you add the List information at the end of the line.
I think that we tested grids during the conference, and found it’s lists only!
Luis I. Gomez
GomezL@CollectionSoftware.com (
GomezL@CollectionSoftware.com)
1-800-435-7257
Commercial Legal Software, Inc.
http://www.CollectionSoftware.com
From: br_forum-bounces@ads.net [mailto:
br_forum-bounces@ads.net]
On Behalf Of Doug Meenen
Sent: Thursday, May 21, 2009 11:32 PM
To: Business Rules Forum
Subject: Re: [BR_forum] Search with Grid / List
Larry,
Here is a subroutine of a List Window with a Search included.
see the attached screen shot "Search_Window.jpg" for the finished product.
The attached srchwin.wbs file is the code.
Pay attention to the line with "sort", this is the key to searching on the name in column 2.
It uses Gabriel's Fileio to build the data for the list, but this is not required - Fileio just makes life easier in the long run.
I think search may work in a grid, but haven't tried that - I have enough problems with grids already.
Doug Meenen
--- On
Thu, 5/21/09, Larry <ltietz@verizon.net> wrote:
From: Larry <
ltietz@verizon.net>
Subject: [BR_forum] Search with Grid / List
To: "'Business Rules Forum'" <
br_forum@ads.net>
Date: Thursday, May 21, 2009, 10:10 PM
One of the cool things I learned about at the conference was that there is a
search feature that can be attached to a grid or a list.
Unfortunately even with sample code from George, hints from Gabriel, I can't
quite make the connection.
First, does this feature work with both lists and grids? Or just one?
Second, is there a reference in any release notes or other documentation.
And, to make life simple, what is the syntax that makes this all work?
Thanks for any help !
_______________________________________________
BR_forum mailing list
BR_forum@ads.net
http://ads.net/mailman/listinfo/br_forum_ads.net