build a search function similar to Microsoft Help in Windows 95 
Author Message
 build a search function similar to Microsoft Help in Windows 95

I would like to build a search function that scrolls through a list as I
key in letter after letter.  Similar to Microsoft Help in Windows 95
under Index.



Sat, 02 Sep 2000 03:00:00 GMT  
 build a search function similar to Microsoft Help in Windows 95

Quote:

>I would like to build a search function that scrolls through a list as I
>key in letter after letter.  Similar to Microsoft Help in Windows 95
>under Index.


First of all your list HAS to be in alpha/numeric order. Then you need two
variables.... Srch$ and SrchLen%.

A binary search routine is handy here.

FUNCTION fBinSearch%(A$(), L%, Srch$ )
  LOCAL F%, M%
                                                   '???????????????
  F% = 1                                           '3 start here
  DO                                               '3 searching
    M% = ( F% + L% ) \ 2                           '3 mid way
    IF M% = F% THEN EXIT LOOP                      '3 bingo!
    IF Srch$ =< A$(M%) THEN L% = M% ELSE F% = M%   '3 which 1/2?
  LOOP                                             '3
                                                   '3
  IF Srch$ > A$(M%) THEN M% = L%                   '3 past it!
  fBinSearch% = M%                                 '3
                                                   '???????????????
END FUNCTION

Next, test if the user presses a key > CHR$(31) and < CHR$(255). If so, and
SrchLen% is less that whatever max you've set then add one to SrchLen%, add
the new char to Srch$ and send it to fBinSearch%. If the LEFT$ of the returned
element equals Srch$ then, you've got a match. If not then strip off the last
letter you've just added.

If the incoming key stroke is NOT a 'letter' then clear Srch$

IF ( C% > 31 ) AND ( C% < 256 ) THEN
    Srch$ = Srch$ + CHR$(C%)
    SrchLen% = SrchLen% + 1
    P% = fBinSearch%( A$(), Last%, Srch$ )
    IF LEFT$( A$(P%), SrchLen% ) <> Srch$ THEN
      SrchLen% = SrchLen% -1
      Srch$ = LEFT$( Srch$, SrchLen% )
    END IF
  ELSE
    SrchLen% = 0
    Srch$ = ""
    ' PROCESS OTHER KEY STROKES HERE
END IF

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|

     www.basicguru.com/schullian



Sun, 03 Sep 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Build a search function similar to Microsoft Help in Windows 95

2. build a search function similar to Microsoft Help in Windows 95

3. One of two functions doesn't function on Windows 95 (i does on Windows NT)

4. Help: API function PlgBlt() for Windows 95 ??

5. Visual Basic 6 run-times requires Windows 95 build 708 or later

6. How Do I Use Windows 95 In Built Cusors

7. Controls Similar To Microsoft Windows Explorer

8. Microsoft Windows 95 don't know calculation

9. Windows 95 B, Setup Wizard Issues Setup.EXE on Windows 95 A

10. Microsoft Windows 95 pop up menu

11. Interface to Microsoft Fax (Windows 95 )

12. Windows 95 B, Setup Wizard Issues Setup.EXE on Windows 95 A

 

 
Powered by phpBB® Forum Software