Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Simple search in a browse 2002-02-21 -- Arnor Baldvinsson I needed to provide a simple search option in my own customer database
program. It had to be able to search on all the fields in the
database and a memo field and I didn't really care in what field it
found the string, as long as it was found. I came up with a very
simple solution that works great on smaller databases.
1. Create a local CString variable for you to enter the search string
in, I made it 256 characters long.
2. In the procedure data embed, create one variable for the file
record and one for each memo you need to search. In my case:
Loc:CustomerStr String(Size(PEO:Record)),OVER(PEO:Record)
Loc:CustMemoStr String(Size(PEO:Comments)),OVER(PEO:Comments)
3. In the ThisWindow.Init method, Open Files embed, bind those
variables:
Bind('Loc:CustomerStr',Loc:CustomerStr)
Bind('Loc:CustMemoStr',Loc:CustMemoStr)
4. Populate your cstring variable that you created in step 1, on the
browse window somewhere.
5. Double click on the entry field and add the following embeds:
Selected:
?Loc:SearchString {Prop:Touched} = True
Accepted:
ThisWindow.Reset(1)
Loc:SearchString was my local cstring variable created in step 1.
6. Right click on the browse, select Actions and for the appropriate
tab (Default or Conditional behaviour) put this filter string in:
Instring(Upper(Loc:SearchString),Upper(Loc:CustomerStr &
Loc:CustMemoStr),1,1)>0
Obviously using your variables etc. where appropriate. That's it.
This can not deal with dates if they are stored in normal Clarion date
format (i.e. numbers) but you could have a special entry field for
searching for dates and then set the Loc:SearchString to the numeric
value from the date entry and it should work fine.
You could spice this up by using the Match() function instead of
Instring() in the filter and then you have lot more search options,
but it will probably be a little bit slower. With the database I
have, the search is instantaneous:)
Later, he adds:
Change this to:
Instring(Upper(Loc:SearchString),Upper(PEO:Record &
PEO:Comments),1,1)>0
In this case you don't need the local variables. I had started out
with them actually for another purpose so I just included them in the
sample:)
Today is November 21, 2024, 3:46 am This article has been viewed 35207 times.
|
|