Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

GotCha (PBDecs)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GotCha (PBDecs)

    GotCha, version 3.26 (2004-05-24 update)

    GotCha is a search engine for PowerBASIC code.
    It can search INC, BAS, BI, H and RC files in a specific folder
    with option to include sub-folders.
    It can be used to search Const, Union, Type, Macro, Function, Subs or Anything
    Search is based on a <Exact/Or/And> string.
    From the result, it can show target file with a combo for Function/Sub.

    Based on Wayne Diamond's PBDecs code.
    Börje's EDM32.inc is needed.
    SMTP.bmp come from SMTP PB/Win sample program ...\Sample\Internet\SMTP\SMTP.bmp

    Thank to Wayne, Börje and Fred.

    Have fun.
    Pierre

    Code:
      
     
    How to proceed for the compilation...
     1) You'l need Borje's excellent EDM32.inc
        it can be found at [url="http://www.reonis.com/POFFS/index.htm"]http://www.reonis.com/POFFS/index.htm[/url] 
     2) Save Code to GotCha.bas, see GotCha.BAS next 2 posts.
     3) Save GotCha.RC, see GotCha .RC post.
     4) Create GotCha.ico, see GotCha.ico section, thank to Edwin.
     5) Copy ...\Sample\Internet\SMTP\SMTP.bmp to GotCha folder.
     6) Create GotCha.PBR with compiler (GotCha.RC/GotCha.ico/SMTP.bmp)
     7) Compile GotCha.exe
      
    Compiler: PB/Win 7.04
    WinApi:   2003-10-27


    [This message has been edited by Pierre Bellisle (edited October 04, 2006).]

  • #2
    Code:
    'GotCha.bas, version 3.26
    'http://www.powerbasic.com/support/forums/Forum7/HTML/001726.html
    'http://www.powerbasic.com/support/pbforums/showthread.php?t=24245
     
    'GotCha is a search engine for PowerBASIC code.
    'It can search INC, H, BAS, BI and RC files in a specific folder
    'with option to include sub-folders.
    'It can be used to search Const, Union, Type, Macro, Function, Subs or Anything
    'Search is based on a <Exact/Or/And> string.
    'File can be shown with a Function/Sub combo.
     
    'New in 3.26 2004-05-24 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    'Added a function for .col help file, like MSDN, thank to Kev Peel
    'Added a label to show line/col/sel
    'Becose Gotcha use left double click for switching text instead of selecting word,
    'the function ctmMouseLButtonDblClk in EDM32.inc must be modified.
    '   In function ctmMouseLButtonDblClk,
    '     everything between
    '       LOCAL ed AS EDM32DATA PTR : ed = GetWindowLong(hWnd, 0)
    '     and
    '       LOCAL nm AS NMHDR
    '     must be remed.
    'Different bacground color when in the "Result" window
     
    'New in 3.25 2004-02-12 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    '"Whole" checkbox added to find whole word.
    'Added file with ".h" extention in search.
    '"File checkBox" added to be able to do a "File ANDed" search instead of a "Line ANDed search".
    'Option "Exact search" now use SpaceShrink function,
    ' meaning searching for "  X   Y " will find " X Y " or " X        Y "
    'Bug corrected, replaced invalid "EOF(FileNo)" call.
    'Last selected preset button will be bold.
    'Command$ goes to search combobox.
    'Control-Down and Control-Up support added in EDM32
     
    'New in 3.24 2003-03-10 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    'Better calling of Poffs (Search 2003-10-03)
     
    'New in 3.23 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Better detection for Poffs dialog handle
     
    'New in 3.22 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' The Editor function is now an Editor/Help function
    '   If Poffs is set it will be started with _
    '    either Combo-Search text or highlighted text.
    '   HLP file can be added, will also be started with _
    '    either Combo-Search text or highlighted text.
    '   CHM file can be added to the list.
    '   Added a Replace button to Editor/Help function
    ' Added 4 preset buttons that memorise Path-Combo and checkbox, _
    '   to memorise a pattern, use Ctrl-Click or Ctrl-(1 to 4)
    ' Added a control to copy text between Search-Combo and Find-Combo.
    ' Added RunExe to contextmenu, exe must exist.
    ' Added Command to contextmenu (Cmd.exe under NT).
    ' Added ShakeDialog for error notification.
    ' Blank Line option is now dynamic.
    ' Many behavior enhancement.
     
    'New in 3.21 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Made "Find in text" case insensitive
     
    'New in 3.20 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Added a Quick-View to see filenames only.
    ' Added an Up-Down control to navigate files in result window.
    ' Added Window-Search to context-menu
    ' Added a Editor function to context-menu that will start the editor _
    '  of your choice with selected file.
    ' Some routine enhancement.
     
    'New in 3.10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Combobox-Path may have many paths separated by ;
    ' Find string in text, set the combo or highlight some text and click Jump or Prev.
    ' Copy, Paste, Explore and Clip-filename added to context-menu.
     
    'New in 3.00 (2003/01/24) - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' You can now search your own .bas, .bi and .rc files.
    ' Some enhancements for user interaction.
    ' Bitmat background stolen from the SMTP PB sample program.
     
    'New in 2.12 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Correction or FolderEnum function.
     
    'New in 2.11 (2003/01/13) - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Corection of %BS_DEFAULT and %WS_TABSTOP style to many control.
    ' Thank to Haitham Yousef.
     
    'New in 2.10 (2003/01/06) - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Added Macro search
    ' Added Else  search
    ' Added Any   search
    ' Added Search inside Union/Type/Macro
    ' Added subDir search
    ' Redesign of search routine
     
    'New in 2.10 (2003/01/01) - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Limited search to 5000 items.
    ' Added GridLine option.
    ' WordWrap, SyntaxHighlight and GridLine options now saved to ini file.
    ' Made it a little bit faster.
    ' Release memory when inc file text no more needed.
    ' Correction: Added "FileNo = FreeFile" before "OPEN FileName FOR BINARY AS FileNo"
     
    'New in 2.00 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ' Added a Combobox that remember the 50 last query.
    ' Added a OpenForder-dialog to set WinApiPath. No need for Command line argument any more.
    ' Added a Combobox that remember many WinApiPAth.
    ' Added Union search.
    ' Radio-Options replaced by Checkbox for Type/Union/Func/Sub/Const.
    ' Added Radio-Options for EXACT/AND/OR searches, words must be separared by space.
    ' Dialog position, size, selected Checkboxs, selected Radio-Options,
    ' ApiPath-Combobox and String-Combobox saved to ini file.
    ' Added wait mouse cursor.
    ' Added an info statusbar
    ' Added name of inc file in statusbar when single-clicking.
    ' Added a view of complete inc file when double-clicking .
    ' Added right-click for WordWrap and SyntaxHighlight flip-flop
     
     
    'Based on Wayne Diamond's excelent PBDecs code. - - - - - - - - - - - - - - - -
     
    'Using amazing Borje's EDM32
    'Borje's EDM32 can be found at http://www.reonis.com/POFFS/index.htm
    '                           or http://www.algonet.se/~hagsten/pb/
    ' For older version of EDM32.inc, in edmTxtReplaceAll function.
    ' Replace
    '    edmUCASE(txt) : edmUCASE(s)
    ' with
    '   edmUCASE txt : edmUCASE s
     
    'SMTP.bmp come from SMTP PB/Win sample program ...\Sample\Internet\SMTP\SMTP.bmp
     
    #COMPILE EXE '#7.04#
    #RESOURCE "GotCha.PBR"
    #INCLUDE  "WIN32API.INC" '2003/10/27
    #INCLUDE  "COMMCTRL.INC"
    #INCLUDE  "COMDLG32.INC"
    #INCLUDE  "EDM32.INC"    'EDM32 Supercool richedit control by Borje Hagsten
     
     
    OPTION EXPLICIT
     
    $AppName = "GotCha"
    $AppVer  = "3.26"
    $Search =  "&Search"
    $Stop   =  "&Stop"
     
    GLOBAL hDlg                   AS DWORD
    GLOBAL hCbSearch              AS DWORD
    GLOBAL hCbFolder              AS DWORD
    GLOBAL hEdm32                 AS DWORD
    GLOBAL hCbFunc                AS DWORD
    GLOBAL hCbFind                AS DWORD
    GLOBAL hStatusbar             AS DWORD
    GLOBAL hMenu                  AS LONG
    GLOBAL CheckItBak             AS LONG
    GLOBAL SearchCancel           AS LONG
    GLOBAL hHook                  AS LONG
    GLOBAL FolderPath             AS STRING
    GLOBAL sOut                   AS STRING
    GLOBAL Editor()               AS STRING
    GLOBAL PresetFolder()         AS STRING
    GLOBAL PresetCheckBox()       AS LONG
    GLOBAL PresetCheckBoxFilter() AS LONG
    GLOBAL PresetCheckBoxSubDir() AS LONG
    GLOBAL Quick                  AS LONG
    GLOBAL PresetLast             AS LONG
     
    %RcIcon            = 102
     
    %ComboFolder       = 1001
    %ButtonFolder      = 1002
    %CheckSubDir       = 1003
     
    %ButtonSet         = 1007
    %ButtonExit        = 1008
    %ButtonHint        = 1009
    %ComboSearch       = 1010
    %ButtonSearch      = 1011
    %ButtonView        = 1012
    %ComboFunc         = 1013
    %ButtonOption      = 1014
    %ComboFind         = 1015
    %ButtonFindNext    = 1016
    %ButtonFindPrev    = 1017
    %LabelFind         = 1018
    %Frame             = 1019
    %UpDownFN          = 1020
    %UpDownFind        = 1021
    %ButtonQuick       = 1022
    %ButtonPreset1     = 1031
    %ButtonPreset2     = 1032
    %ButtonPreset3     = 1033
    %ButtonPreset4     = 1034
    %LabelPreset       = 1035
    %LabelLineCol      = 1036
     
    %CheckConst        = 2001
    %CheckUnion        = 2002
    %CheckType         = 2003
    %CheckMacro        = 2004
    %CheckFunc         = 2005
    %CheckSub          = 2006
    %CheckElse         = 2007
    %CheckAny          = 2011
    %CheckInside       = 2021
    %LabelInside       = 2022
    %CheckFile         = 2023
    %CheckWhole        = 2031
     
    %RadioExact        = 3001
    %RadioAnd          = 3002
    %RadioOr           = 3003
    %LabelExactAndOr   = 3004
     
    %EDM32             = 4001
    %StatusBar         = 5001
     
    %FindExact         = 0001
    %FindAnd           = 0002
    %FindOr            = 0003
     
    %PopWrap           = 6001
    %PopSyntax         = 6002
    %PopGrid           = 6003
    %PopBlank          = 6004
    %PopCopy           = 6005
    %PopPaste          = 6006
    %PopExplore        = 6007
    %PopClipFN         = 6008
    %PopWinSearch      = 6009
    %PopRunExe         = 6010
    %PopCommand        = 6011
    %PopEditorAdd      = 6100
    %PopEditorSep      = 6101
     
    %CheckInc          = 7001
    %CheckBas          = 7002
     
    %LabelEdName       = 8001
    %ButtonEdDel       = 8002
    %ListboxEd         = 8003
    %TextboxEdName     = 8004
    %LabelEdPath       = 8005
    %TextboxEdPath     = 8006
    %ButtonEdBrowse    = 8007
    %ButtonEdAdd       = 8008
    %ButtonEdOk        = 8009
    %ButtonEdCancel    = 8011
    %ButtonEdRep       = 8012
     
    %HH_KEYWORD_LOOKUP = 0013
     
    TYPE HH_AKLINK
     cbStruct     AS LONG
     fReserved    AS LONG
     pszKeywords  AS ASCIIZ PTR
     pszUrl       AS ASCIIZ PTR
     pszMsgText   AS ASCIIZ PTR
     pszMsgTitle  AS ASCIIZ PTR
     pszWindow    AS ASCIIZ PTR
     fIndexOnFail AS LONG
    END TYPE
     
    DECLARE FUNCTION HtmlHelp LIB "hhctrl.ocx" ALIAS "HtmlHelpA" (BYVAL hwndCaller AS DWORD, _
                     pszFile AS ASCIIZ, BYVAL uCommand AS DWORD, BYVAL dwData AS DWORD ) AS DWORD
    '________________________________________________________________________________________________
     
    FUNCTION IsNt() AS LONG
     LOCAL VInfo AS OSVERSIONINFO
     
     VInfo.dwOsVersionInfoSize = SIZEOF(VInfo)
     GetVersionEx VInfo
     FUNCTION = (VInfo.dwPlatformId = %VER_PLATFORM_WIN32_NT)
     
    End Function
    '________________________________________________________________________________________________
     
    Function FileExist(FILENAME AS STRING) AS LONG
     
     FileExist = DIR$(FILENAME,  &hA7) <> ""
     
    End Function
    '_____________________________________________________________________________________________
     
    SUB ShakeDialog(hDlgToShake AS LONG)
     LOCAL X       AS LONG
     LOCAL Y       AS LONG
     LOCAL Counter AS LONG
     
     DIALOG GET LOC hDlgToShake TO X, Y
     FOR Counter = 1 to 2
       DIALOG SET LOC hDlgToShake, X + 1, Y + 1
       SLEEP 30
       DIALOG SET LOC hDlgToShake, X, Y
       SLEEP 30
     NEXT
     
    END SUB
    '______________________________________________________________________________
     
    FUNCTION CenterNextDialog(BYVAL lMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
     LOCAL rc1 AS RECT
     LOCAL rc2 AS RECT
     
     IF lMsg = %HCBT_ACTIVATE THEN
       GetWindowRect GetDesktopWindow, rc1: GetWindowRect wParam, rc2
       SetWindowPos wParam, %HWND_TOPMOST, (rc1.nLeft + rc1.nRight - rc2.nRight + rc2.nLeft) / 2 , _
        (rc1.nTop + rc1.nBottom - rc2.nBottom + rc2.nTop) / 2, 0, 0, %SWP_NOSIZE OR %SWP_NOACTIVATE
     END IF
     UnhookWindowsHookEx hHook
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PopEditorDel() AS LONG
     LOCAL Counter AS LONG
     
     IF UBOUND(Editor()) > 0 THEN
       FOR Counter = 1 TO UBOUND(Editor())
         MENU DELETE hMenu, BYCMD Counter + %PopEditorSep
       NEXT
       Counter = GetMenuItemCount(hMenu)
       MENU DELETE hMenu, Counter - 1 '%PopEditorSep
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PopEditorAdd() AS LONG
     LOCAL Counter AS LONG
     LOCAL Buffer  AS STRING
     
     IF UBOUND(Editor()) > 0 THEN
       MENU ADD STRING, hmenu, "-", %PopEditorSep, %MF_ENABLED
       FOR Counter = 1 TO UBOUND(Editor())
         Buffer = PARSE$(Editor(Counter), $TAB, 1)
         MENU ADD STRING, hmenu, Buffer, %PopEditorSep + Counter, %MF_ENABLED
       NEXT
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION BrowseFile(hWndOwner AS LONG, StartPath AS STRING) AS STRING
     LOCAL sFile       AS STRING
     LOCAL ofn         AS OPENFILENAME
     LOCAL szTitle     AS ASCIIZ * 50
     LOCAL sFilter     AS STRING
     LOCAL szFileTitle AS ASCIIZ * %MAX_PATH
     LOCAL zInitialDir AS ASCIIZ * %MAX_PATH
     
        'To Center OpenFileDialog:
        hHook = SetWindowsHookEx(%WH_CBT, CODEPTR(CenterNextDialog), GetModuleHandle(BYVAL 0&), GetCurrentThreadId) 'Center Dialog
     
        szTitle              = $AppName & " - Editor/Help file - Add"
        ofn.lpstrTitle       = VARPTR(szTitle)
     
        sFilter             = "Exe Files  (*.exe)"             & $NUL & "*.exe" & $NUL _
                            & "Help Files (*.hlp)"             & $NUL & "*.hlp" & $NUL _
                            & "Help Files (*.chm)"             & $NUL & "*.chm" & $NUL _
                            & "Help Files (*.col)"             & $NUL & "*.col" & $NUL _
                            & "Help All (*.hlp, *.chm, *.col)" & $NUL & "*.hlp;*.chm;*.col" & $NUL _
                            & "All Files  (*.*)"               & $NUL & "*.*"   & $NUL & $NUL
     
        ofn.lpstrFilter     = STRPTR(sFilter)
        ofn.lpstrFileTitle  = VARPTR(szFileTitle)
        ofn.nMaxFileTitle   = SIZEOF(szFileTitle)
     
        sFile               = STRING$(%Max_Path, 0)
        ofn.lpstrFile       = STRPTR(sFile)   'Returned path\filename
        ofn.nMaxFile        = LEN(sFile)
     
        ofn.lStructSize     = SIZEOF(ofn)
        ofn.hWndOwner       = hWndOwner 'hDlg
        ofn.nFilterIndex    = 1
     
     
        zInitialDir         = StartPath
        ofn.lpstrInitialDir = VARPTR(zInitialDir)
     
        ofn.Flags = %OFN_EXPLORER OR %OFN_ENABLESIZING OR _
                    %OFN_FILEMUSTEXIST OR %OFN_NODEREFERENCELINKS OR %OFN_HIDEREADONLY
     
        IF GetOpenFileName(ofn) = 0 THEN 'Error if 0
     
        ELSE
          FUNCTION = sFile         'Path\File
        END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    SUB HelpCol(BYVAL sFile AS STRING, BYVAL sKeyword AS STRING) 'Thank to Kev Peel
     LOCAL ColHelp AS HH_AKLINK
     LOCAL hLib    AS DWORD
     LOCAL dwProc  AS DWORD
     
     hLib = LoadLibrary("hhctrl.ocx")
     IF hLib THEN
       dwProc = GetProcAddress(hLib, "HtmlHelpA")
       IF dwProc THEN
         IF LEN(sKeyword) THEN ColHelp.pszKeywords = STRPTR(sKeyword)
         ColHelp.cbStruct      = SIZEOF(ColHelp)
         ColHelp.fReserved     = %FALSE
         ColHelp.pszUrl        = %NULL
         ColHelp.pszMsgText    = %NULL
         ColHelp.pszMsgTitle   = %NULL
         ColHelp.pszWindow     = %NULL
         ColHelp.fIndexOnFail  = %TRUE
         CALL DWORD dwProc USING HtmlHelp(0, BYCOPY sFile, %HH_KEYWORD_LOOKUP, VARPTR(ColHelp))
       END IF
       FreeLibrary hLib
     END IF
     
    END SUB
    '______________________________________________________________________________
     
    CALLBACK FUNCTION EditorGetProc() AS LONG
     LOCAL  EdName       AS STRING
     LOCAL  EdPath       AS STRING
     LOCAL  EdNamePath   AS STRING
     LOCAL  Buffer       AS STRING
     LOCAL  Counter      AS LONG
     LOCAL  Retval       AS LONG
     LOCAL  ListboxCount AS LONG
     LOCAL  TabLen       AS LONG
     STATIC hListboxEd   AS LONG
     
     SELECT CASE CBMSG
       CASE %WM_INITDIALOG
     
         'Dirty trick here, Tab is so long that only EdName will appear in listbox, EdPath won't appear
         TabLen = 500
         CALL SendMessage(hListboxEd, %LB_SETTABSTOPS, 1, VARPTR(TabLen))
         FOR Counter = 1 TO UBOUND(Editor())
           LISTBOX ADD CBHNDL, %ListboxEd, Editor(Counter)
         NEXT
     
       CASE %WM_COMMAND
         SELECT CASE CBCTL
     
           CASE %ButtonEdAdd
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL GET TEXT CBHNDL, %TextboxEdName TO EdName
               CONTROL GET TEXT CBHNDL, %TextboxEdPath TO EdPath
               EdName = TRIM$(EdName)
               EdPath = TRIM$(EdPath)
               IF ISTRUE(LEN(EdName)) AND ISTRUE(LEN(EdPath)) THEN
                 EdNamePath = EdName & $TAB & EdPath
                 ListboxCount = SendMessage(hListBoxEd, %LB_GETCOUNT, 0, 0)
                 FOR Counter = 1 TO ListboxCount
                   Buffer = STRING$(%MAX_PATH * 2, 0)
                   SendMessage hListBoxEd, %LB_GETTEXT, Counter - 1, STRPTR(Buffer)
                   Buffer = REMOVE$(Buffer, $NUL)
                   Buffer = PARSE$(Buffer , $TAB, 1)
                   IF LCASE$(Buffer) = LCASE$(EdName) THEN
                     LISTBOX DELETE CBHNDL, %ListboxEd, Counter
                     EXIT FOR
                   END IF
                 NEXT
                 LISTBOX ADD CBHNDL, %ListboxEd, EdNamePath
                 Retval = SendMessage(hListBoxEd, %LB_FINDSTRING, 0, STRPTR(EdNamePath))
                 SendMessage hListBoxEd, %LB_SETCURSEL, Retval, 0
               ELSE
                 BEEP
                 ShakeDialog CBHNDL
               END IF
             END IF
     
           CASE %ButtonEdRep
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL GET TEXT CBHNDL, %TextboxEdName TO EdName
               CONTROL GET TEXT CBHNDL, %TextboxEdPath TO EdPath
               EdName = TRIM$(EdName)
               EdPath = TRIM$(EdPath)
               IF ISTRUE(LEN(EdName)) AND ISTRUE(LEN(EdPath)) THEN
                 Retval = SendMessage(hListboxEd, %LB_GETCURSEL, 0, 0)
                 IF Retval > -1 THEN
                   LISTBOX DELETE CBHNDL, %ListboxEd, Retval + 1
                   EdNamePath = EdName & $TAB & EdPath
                   ListboxCount = SendMessage(hListBoxEd, %LB_GETCOUNT, 0, 0)
                   FOR Counter = 1 TO ListboxCount
                     Buffer = STRING$(%MAX_PATH * 2, 0)
                     SendMessage hListBoxEd, %LB_GETTEXT, Counter - 1, STRPTR(Buffer)
                     Buffer = REMOVE$(Buffer, $NUL)
                     Buffer = PARSE$(Buffer , $TAB, 1)
                     IF LCASE$(Buffer) = LCASE$(EdName) THEN
                       LISTBOX DELETE CBHNDL, %ListboxEd, Counter
                       EXIT FOR
                     END IF
                   NEXT
                   LISTBOX ADD CBHNDL, %ListboxEd, EdNamePath
                   Retval = SendMessage(hListBoxEd, %LB_FINDSTRING, 0, STRPTR(EdNamePath))
                   SendMessage hListBoxEd, %LB_SETCURSEL, Retval, 0
                 ELSE
                   BEEP
                   ShakeDialog CBHNDL
                 END IF
               ELSE
                 BEEP
                 ShakeDialog CBHNDL
               END IF
             END IF
     
           CASE %ButtonEdDel
             IF CBCTLMSG = %BN_CLICKED THEN
               Retval = SendMessage(hListboxEd, %LB_GETCURSEL, 0, 0)
               IF Retval > -1 THEN
                 LISTBOX DELETE CBHNDL, %ListboxEd, Retval + 1
                 CONTROL SET TEXT CBHNDL, %TextboxEdName, ""
                 CONTROL SET TEXT CBHNDL, %TextboxEdPath, ""
               ELSE
                 BEEP
                 ShakeDialog CBHNDL
               END IF
             END IF
     
           CASE %ListboxEd
             IF CBCTLMSG = %LBN_SELCHANGE THEN
               Retval = SendMessage(hListboxEd, %LB_GETCURSEL, 0, 0)
               IF Retval > -1 THEN
                 LISTBOX GET TEXT CBHNDL, %ListboxEd TO EdNamePath
                 CONTROL SET TEXT CBHNDL, %TextboxEdName, PARSE$(EdNamePath , $TAB, 1)
                 CONTROL SET TEXT CBHNDL, %TextboxEdPath, PARSE$(EdNamePath , $TAB, 2)
               END IF
             END IF
     
           CASE %ButtonEdBrowse
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL GET TEXT CBHNDL, %TextboxEdPath TO Buffer
               Retval = INSTR(-1, Buffer, "\")
               IF Retval THEN
                 Buffer = LEFT$(Buffer, Retval - 1)
               ELSE
                 Buffer = CURDIR$
               END IF
               Buffer = BrowseFile(CBHNDL, Buffer)
               IF LEN(Buffer) THEN
                 CONTROL SET TEXT CBHNDL, %TextboxEdPath, Buffer
               END IF
             END IF
     
           CASE %ButtonEdOk
             IF CBCTLMSG = %BN_CLICKED THEN
               PopEditorDel
               ListboxCount = SendMessage(hListBoxEd, %LB_GETCOUNT, 0, 0)
               REDIM Editor(0 TO ListboxCount)
               FOR Counter = 1 TO ListboxCount
                 Buffer = STRING$(%MAX_PATH * 2, 0)
                 SendMessage hListBoxEd, %LB_GETTEXT, Counter - 1, STRPTR(Buffer)
                 Editor(Counter) = REMOVE$(Buffer, $NUL)
               NEXT
               PopEditorAdd
               DIALOG END CBHNDL, 0
             END IF
     
           CASE %ButtonEdCancel, %IDCANCEL
             IF CBCTLMSG = %BN_CLICKED THEN DIALOG END CBHNDL, 0
     
         END SELECT
     
     END SELECT
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION EditorGet() AS LONG
     LOCAL hEditorDlg AS LONG
     
     DIALOG NEW hDlg, $AppName & " - Editor/Help file", , , 195, 135, _
                 %WS_POPUP OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_CAPTION OR _
                 %WS_SYSMENU OR  %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
                 %WS_EX_CONTROLPARENT TO hEditorDlg
     
     CONTROL ADD LABEL, hEditorDlg, %LabelEdName, "Name to display", 3, 3, 66, 12, _
                 %WS_CHILD OR %WS_VISIBLE
     
     CONTROL ADD TEXTBOX, hEditorDlg, %TextboxEdName, "", 3, 15, 186, 12, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
     
     CONTROL ADD LABEL, hEditorDlg, %LabelEdPath, ".exe, .hlp, .col or .chm full path " & _
                 "(Poffs may be added)", 3, 30, 165, 12, %WS_CHILD OR %WS_VISIBLE
     
     CONTROL ADD TEXTBOX, hEditorDlg, %TextboxEdPath, "", 3, 42, 186, 12, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
     
     CONTROL ADD LISTBOX, hEditorDlg, %ListboxEd, , 3, 66, 96, 72, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %WS_VSCROLL OR %WS_TABSTOP _
                 OR %LBS_NOTIFY OR %LBS_SORT OR %LBS_USETABSTOPS, %WS_EX_CLIENTEDGE
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdAdd, "&Add", 111, 66, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdDel, "&Del", 111, 90, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdRep, "&Repl", 111, 114, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdBrowse, "&Browse", 153, 66, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdCancel, "&Cancel", 153, 90, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     CONTROL ADD BUTTON, hEditorDlg, %ButtonEdOk, "&OK", 153, 114, 33, 15, _
                 %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_CENTER OR %BS_VCENTER
     
     DIALOG SHOW MODAL hEditorDlg, CALL EditorGetProc
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ControlSetSize() AS LONG
     LOCAL CSizeX       AS LONG
     LOCAL CSizeY       AS LONG
     
     DIALOG GET CLIENT hDlg TO CSizeX, CSizeY
     CONTROL SET SIZE hDlg, %EDM32, CSizeX - 0, CSizeY - 90 '3 '(74 + 19)
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION RadioGet() AS LONG
     LOCAL Retval AS LONG
     
     FUNCTION = %FindExact
     CONTROL GET CHECK hDlg, %RadioAnd TO Retval : IF Retval THEN FUNCTION = %FindAnd
     CONTROL GET CHECK hDlg, %RadioOr  TO Retval : IF Retval THEN FUNCTION = %FindOr
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION RadioSetLabel(RadioButton AS LONG) AS LONG
     
     CONTROL SHOW STATE hDlg, %LabelExactAndOr, %SW_HIDE
     SELECT CASE RadioButton
       CASE %RadioExact
         CONTROL SET TEXT hDlg, %LabelExactAndOr, "Exact string, spaces shrinked"
       CASE %RadioAnd
         CONTROL SET TEXT hDlg, %LabelExactAndOr, "All words"
       CASE %RadioOr
         CONTROL SET TEXT hDlg, %LabelExactAndOr, "Any words"
     END SELECT
     CONTROL SHOW STATE hDlg, %LabelExactAndOr, %SW_SHOWNORMAL
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION CheckBoxGet() AS LONG
     LOCAL Checked AS LONG
     LOCAL CheckIt AS LONG
     
     CONTROL GET CHECK hDlg, %CheckConst TO Checked
     IF Checked = 1 THEN CheckIt = 1 ELSE CheckIt = 0
     CONTROL GET CHECK hDlg, %CheckUnion TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 2
     CONTROL GET CHECK hDlg, %CheckType TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 4
     CONTROL GET CHECK hDlg, %CheckMacro TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 8
     CONTROL GET CHECK hDlg, %CheckFunc TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 16
     CONTROL GET CHECK hDlg, %CheckSub TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 32
     CONTROL GET CHECK hDlg, %CheckElse TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 128
     CONTROL GET CHECK hDlg, %CheckAny TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 512
     CONTROL GET CHECK hDlg, %CheckInside TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 1024
     CONTROL GET CHECK hDlg, %CheckFile TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 2048
     
     FUNCTION = CheckIt
     
    END FUNCTION
     
    '______________________________________________________________________________
     
    FUNCTION CheckBoxSet(CheckIt AS LONG) AS LONG
     
     IF ISTRUE(CheckIt AND 1)    THEN CONTROL SET CHECK hDlg, %CheckConst,  1  _
                                 ELSE CONTROL SET CHECK hDlg, %CheckConst,  0
     IF ISTRUE(CheckIt AND 2)    THEN CONTROL SET CHECK hDlg, %CheckUnion,  1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckUnion,  0
     IF ISTRUE(CheckIt AND 4)    THEN CONTROL SET CHECK hDlg, %CheckType,   1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckType,   0
     IF ISTRUE(CheckIt AND 8)    THEN CONTROL SET CHECK hDlg, %CheckMacro,  1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckMacro,  0
     IF ISTRUE(CheckIt AND 16)   THEN CONTROL SET CHECK hDlg, %CheckFunc,   1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckFunc,   0
     IF ISTRUE(CheckIt AND 32)   THEN CONTROL SET CHECK hDlg, %CheckSub,    1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckSub,    0
     IF ISTRUE(CheckIt AND 128)  THEN CONTROL SET CHECK hDlg, %CheckElse,   1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckElse,   0
     IF ISTRUE(CheckIt AND 512)  THEN CONTROL SET CHECK hDlg, %CheckAny,    1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckAny,    0
     IF ISTRUE(CheckIt AND 1024) THEN CONTROL SET CHECK hDlg, %CheckInside, 1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckInside, 0
     IF ISTRUE(CheckIt AND 2048) THEN CONTROL SET CHECK hDlg, %CheckFile,   1 _
                                 ELSE CONTROL SET CHECK hDlg, %CheckFile,   0
     
     IF CheckIt = 1 + 2 + 4 + 8 + 16 + 32 THEN
       CONTROL SET TEXT hDlg, %ButtonSet, "Rese&t"
     ELSE
       IF CheckIt < 128 THEN CONTROL SET TEXT hDlg, %ButtonSet, "Se&t"
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION CheckBoxFilterGet() AS LONG
     LOCAL Checked AS LONG
     LOCAL CheckIt AS LONG
     
     CONTROL GET CHECK hDlg, %CheckInc TO Checked
     IF Checked = 1 THEN CheckIt = 1 ELSE CheckIt = 0
     CONTROL GET CHECK hDlg, %CheckBas TO Checked
     IF Checked = 1 THEN CheckIt = CheckIt + 2
     
     FUNCTION = CheckIt
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION CheckBoxFilterSet(CheckIt AS LONG) AS LONG
     
     IF ISTRUE(CheckIt AND 1) THEN CONTROL SET CHECK hDlg, %CheckInc,  1 _
                              ELSE CONTROL SET CHECK hDlg, %CheckInc,  0
     IF ISTRUE(CheckIt AND 2) THEN CONTROL SET CHECK hDlg, %CheckBas,  1 _
                              ELSE CONTROL SET CHECK hDlg, %CheckBas,  0
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION FolderEnum(Folder() AS STRING) AS LONG  'Return a folder array
     LOCAL  FolderFound AS WIN32_FIND_DATA
     LOCAL  hFolder     AS LONG
     LOCAL  FolderCount AS LONG
     LOCAL  Counter     AS LONG
     STATIC FolderTotal AS LONG
     STATIC FolderAll() AS STRING
     
     DIM SearchFor(0 TO 0) AS STRING
     IF LEFT$(CALLSTK$(2), 11) <> "FOLDERENUM(" THEN  'First call, not auto-recursive yet.
       DIM SubFolder(0 TO 0) AS STATIC STRING
       IF ASC(Folder(0) , - 1) <> 92 THEN Folder(0) = Folder(0) & "\"
       SearchFor(0) = Folder(0)
       FolderTotal = 0
       STATIC FolderZero AS STRING
       FolderZero = Folder(0) 'Neened to put initial path back into Folder(0)
     ELSE
       SearchFor(0) = SubFolder(0)
     END IF
     
     hFolder = FindFirstFile(BYCOPY SearchFor(0) & "*.*", FolderFound)
     IF hFolder = %INVALID_HANDLE_VALUE THEN EXIT FUNCTION
     DO
       IF ISTRUE(FolderFound.dwFileAttributes AND %FILE_ATTRIBUTE_DIRECTORY) THEN
         IF FolderFound.cFilename <> "." AND FolderFound.cFilename <> ".." THEN
           INCR FolderCount
           REDIM PRESERVE SearchFor(0 TO FolderCount)
           SearchFor(FolderCount) = SearchFor(0) & FolderFound.cFilename & "\"
           INCR FolderTotal
           REDIM PRESERVE FolderAll(0 TO FolderTotal)
           FolderAll(FolderTotal) = SearchFor(FolderCount)
         END IF
       END IF
     LOOP WHILE FindNextFile(hFolder, FolderFound)
     
     FOR Counter = 1 TO FolderCount
         SubFolder(0) = SearchFor(Counter)
         FolderEnum SubFolder()
     NEXT
     FindClose hFolder
     
     IF LEFT$(CALLSTK$(2), 11) <> "FOLDERENUM(" THEN  'First call, exitting, auto-recursive is done.
       REDIM Folder(0 TO FolderTotal)
       Folder(0) = FolderZero 'Put caller initial path back into Folder(0)
       FOR Counter = 1 TO FolderTotal
         Folder(Counter) = FolderAll(Counter)
       NEXT
       FolderZero = ""
       ERASE SubFolder()
       ERASE FolderAll()
       FUNCTION = FolderTotal
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION FolderGetArray(Folder() AS STRING) AS LONG
     LOCAL RootCount        AS LONG
     LOCAL FolderCount      AS LONG
     LOCAL Counter          AS LONG
     LOCAL Retval           AS LONG
     LOCAL CounterTotal     AS LONG
     LOCAL FolderCountTotal AS LONG
     
     RootCount = PARSECOUNT(FolderPath, ";")
     DIM FolderRoot(1 TO RootCount) AS STRING
     PARSE FolderPath, FolderRoot(), ";"
     
     FOR Counter = 1 TO RootCount
       FolderRoot(Counter) = TRIM$(FolderRoot(Counter))
       IF ASC(FolderRoot(Counter), - 1) <> 92 THEN FolderRoot(Counter) = FolderRoot(Counter) & "\"
     NEXT Counter
     
     CONTROL GET CHECK hDlg, %CheckSubDir TO Retval
     IF Retval THEN 'Include sub-dir
       FOR Counter = 1 TO RootCount
         REDIM FolderArray(0 TO 0) AS STRING
         FolderArray(0) = FolderRoot(Counter)
         FolderCount = FolderEnum(FolderArray())
         FOR CounterTotal = 0 TO FolderCount
           INCR FolderCountTotal
           REDIM PRESERVE Folder(0 TO FolderCountTotal)
           Folder(FolderCountTotal) = FolderArray(CounterTotal)
         NEXT
       NEXT
       FUNCTION = FolderCountTotal
     ELSE 'No sub-dir
       REDIM Folder(1 TO RootCount) AS STRING
       FOR Counter = 1 TO RootCount
         Folder(Counter) = FolderRoot(Counter)
       NEXT Counter
       FUNCTION = RootCount
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    CALLBACK FUNCTION BrowseFolderProc 'Thanks to Fred Oxenby
     LOCAL zBuffer AS ASCIIZ * %MAX_PATH
     
     IF CBMSG = %BFFM_INITIALIZED THEN
     
       DIALOG SEND CBHNDL, %BFFM_SETSELECTION, %TRUE, CBLPARAM
     
     ELSEIF CBMSG = %BFFM_SELCHANGED THEN
     
       CALL SHGetPathFromIDList(BYVAL CBWPARAM, zBuffer)
     
       IF ISFALSE CBWPARAM OR _                        ' No id number
         ISFALSE LEN(zBuffer) OR _                     ' No name
         ISFALSE (GETATTR(zBuffer) AND %SubDIR) OR _   ' Not a real subdir or file enable
         MID$(zBuffer, 2, 1) <> ":" THEN               ' Not a local or mapped drive
           DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       ELSEIF (GETATTR(zBuffer) AND %SYSTEM) AND RIGHT$(zBuffer, 2) <> ":\" THEN
         'Exclude system folders, allow root directories
         DIALOG SEND CBHNDL, %BFFM_ENABLEOK, %FALSE, %FALSE
       END IF
     
       IF LEN(zBuffer) > 50 THEN 'Ellipsis:  C:\RootFolder ... DeepFolder
         zBuffer = LEFT$(zBuffer, 25) & " ... " & RIGHT$(zBuffer, 25)
       END IF
       SendMessage CBHNDL, %BFFM_SETSTATUSTEXT, 0, VARPTR(zBuffer)
     
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION BrowseFolder(hWnd AS LONG, Title AS STRING, StartFolder AS STRING) AS STRING 'Thanks to Fred Oxenby
     LOCAL zBuffer  AS ASCIIZ * %MAX_PATH
     LOCAL bi       AS BROWSEINFO
     LOCAL lpIDList AS LONG
     
     bi.hWndOwner    = hWnd
     bi.lpszTitle    = STRPTR(Title)
     bi.ulFlags      = %BIF_RETURNONLYFSDIRS OR %BIF_DONTGOBELOWDOMAIN OR %BIF_RETURNFSANCESTORS _
                       OR %BIF_NEWDIALOGSTYLE  OR %BIF_STATUSTEXT
     bi.lpfnCallback = CODEPTR(BrowseFolderProc)
     bi.lParam = STRPTR(StartFolder)
     lpIDList = SHBrowseForFolder(bi)
     
     IF ISTRUE lpIDList AND SHGetPathFromIDList(BYVAL lpIDList, zBuffer) THEN
       FUNCTION = zBuffer
       CoTaskMemFree lpIDList
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ExeName() AS STRING 'Return the exe filename of this app.
     LOCAL FileName    AS ASCIIZ * %Max_Path
     LOCAL FileNameLen AS LONG
     LOCAL hInstance   AS LONG
     
     FileNameLen = GetModuleFileName(hInstance, FileName, %Max_Path)
     FUNCTION = LEFT$(FileName, FileNameLen)
     
    END FUNCTION
    '______________________________________________________________________________
     
    SUB FontMakeBold(ControlId AS LONG, Action AS LONG)
     STATIC hFontBold AS DWORD
     STATIC hFont     AS DWORD
     LOCAL  lf        AS LOGFONT
     
     SELECT CASE Action
       CASE 0 'Create bold font
         hFont = SendMessage(hDlg, %WM_GETFONT, 0, 0)
         GetObject hFont, SIZEOF(lf), BYVAL VARPTR(lf)
         lf.lfWeight = %FW_BOLD
         hFontBold = CreateFontIndirect(lf)
     
       CASE 1 'Set normal
         CONTROL SEND hDlg, ControlId, %WM_SETFONT, hFont, %TRUE
     
       CASE 2 'Set bold
         CONTROL SEND hDlg, ControlId, %WM_SETFONT, hFontBold, %TRUE
     
       CASE 3 'Delete bold font
         DeleteObject hFontBold
     
     END SELECT
     
    END SUB
    '______________________________________________________________________________
     
    FUNCTION IniFileSave() AS LONG  'App. is about to end, so it's time to save our dialog coordinates.
     LOCAL FileName AS STRING
     LOCAL FileNo   AS LONG
     LOCAL Zoomed   AS LONG
     LOCAL WinPla   AS WINDOWPLACEMENT
     LOCAL cbCount  AS LONG
     LOCAL Buffer   AS STRING
     LOCAL Counter  AS LONG
     LOCAL Retval   AS LONG
     
     WinPla.Length = SIZEOF(WinPla)
     IF GetWindowPlacement(hDlg, WinPla) THEN
       IF WinPla.showCmd = %SW_SHOWMAXIMIZED THEN Zoomed = 1 'Does our dialog is maximized?
       FileName = LEFT$(ExeName, LEN(ExeName) - 3) & "ini"   'Set the ini filename to fit with the exe filename.
       FileNo = FREEFILE
       OPEN FileName FOR OUTPUT AS FileNo                                   'Ini file creation/rewrite
     
       PRINT # FileNo, "[Dialog]"                                         'Write a [Dialog] section.
       PRINT # FileNo, "Left ="   & STR$(WinPla.rcNormalPosition.nLeft)   'Write horizontal left position.
       PRINT # FileNo, "Right ="  & STR$(WinPla.rcNormalPosition.nRight)  'Write horizontal right position.
       PRINT # FileNo, "Top ="    & STR$(WinPla.rcNormalPosition.nTop)    'Write vertical top position.
       PRINT # FileNo, "Bottom =" & STR$(WinPla.rcNormalPosition.nBottom) 'Write vertical bottom position.
       PRINT # FileNo, "Zoomed =" & STR$(Zoomed)                          'Write maximized status.
       PRINT # FileNo, "CheckBoxMark =" & STR$(CheckBoxGet)               'Write witch checkbox are marked.
       PRINT # FileNo, "CheckBoxBak =" & STR$(CheckItBak)                 'Write witch previous checkbox are marked.
       PRINT # FileNo, "Radio =" & STR$(RadioGet)                         'Write witch radio is marked.
       CONTROL GET CHECK hDlg, %CheckWhole TO Retval
       PRINT # FileNo, "Whole =" & STR$(Retval)                           'Write Whole.
       CONTROL GET CHECK hDlg, %CheckSubDir TO Retval
       PRINT # FileNo, "SubFolder =" & STR$(Retval)                       'Write SubFolder check status.
       CALL SendMessage(hEdm32, %EDM_GETWORDWRAP, 0, 0) TO Retval
       PRINT # FileNo, "WordWrap =" & STR$(Retval)                        'Write word wrap status.
       CALL SendMessage(hEdm32, %EDM_GETSYNTAXONOFF, 0, 0) TO Retval
       PRINT # FileNo, "SyntaxHighlight =" & STR$(Retval)                 'Write syntax highlight status.
       CALL SendMessage(hEdm32, %EDM_GETGRID, 0, 0) TO Retval
       PRINT # FileNo, "GridLine =" & STR$(Retval)                        'Write grid line status.
       MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
       PRINT # FileNo, "BlankLine =" & STR$(Retval)                       'Write blank line status.
       PRINT # FileNo, "Filter =" & STR$(CheckBoxFilterGet)               'Write file filter status.
       PRINT # FileNo, "Quick =" & STR$(Quick)
     
       cbCount = SendMessage(hCbSearch, %CB_GETCOUNT, 0, 0)
       IF cbCount THEN
         PRINT # FileNo, "[Strings]"
         FOR Counter = 0 TO cbCount - 1
           Buffer = SPACE$(SendMessage(hCbSearch, %CB_GETLBTEXTLEN, Counter, 0) + 1)
           CALL SendMessage(hCbSearch, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
           PRINT # FileNo, "Item = " & Buffer
         NEXT
       END IF
     
       cbCount = SendMessage(hCbFolder, %CB_GETCOUNT, 0, 0)
       IF cbCount THEN
         PRINT # FileNo, "[FilePath]"
         FOR Counter = 0 TO cbCount - 1
           Buffer = SPACE$(SendMessage(hCbFolder, %CB_GETLBTEXTLEN, Counter, 0) + 1)
           CALL SendMessage(hCbFolder, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
           PRINT # FileNo, "Folder = " & Buffer
         NEXT
       END IF
     
       cbCount = SendMessage(hCbFind, %CB_GETCOUNT, 0, 0)
       IF cbCount THEN
         PRINT # FileNo, "[Find]"
         FOR Counter = 0 TO cbCount - 1
           Buffer = SPACE$(SendMessage(hCbFolder, %CB_GETLBTEXTLEN, Counter, 0) + 1)
           CALL SendMessage(hCbFind, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
           IF LEN(LTRIM$(Buffer)) THEN
             PRINT # FileNo, "Target = " & Buffer
           END IF
         NEXT
       END IF
     
       cbCount = UBOUND(Editor())
       IF cbCount THEN
         PRINT # FileNo, "[Editor]"
         FOR Counter = 1 TO cbCount
           PRINT # FileNo, PARSE$(Editor(Counter) , $TAB, 1) & " = " & PARSE$(Editor(Counter) , $TAB, 2)
         NEXT
       END IF
     
       PRINT # FileNo, "[Preset]"
       FOR Counter = 1 TO 4
         PRINT # FileNo, "PresetLast =" & STR$(PresetLast)
         PRINT # FileNo, "Folder" & FORMAT$(Counter) & " = " & PresetFolder(Counter)
         PRINT # FileNo, "Search" & FORMAT$(Counter) & " ="  & STR$(PresetCheckBox(Counter))
         PRINT # FileNo, "File"   & FORMAT$(Counter) & "   ="  & STR$(PresetCheckBoxFilter(Counter))
         PRINT # FileNo, "Subdir" & FORMAT$(Counter) & " ="  & STR$(PresetCheckBoxSubDir(Counter))
       NEXT
     
     CLOSE FileNo
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION IniFileRead() AS LONG 'Restore previous coordinates.
     LOCAL Buffer    AS STRING
     LOCAL FileName  AS STRING
     LOCAL FileNo    AS LONG
     LOCAL Zoomed    AS LONG
     LOCAL CheckIt   AS LONG
     LOCAL RadioSet  AS LONG
     LOCAL Retval    AS LONG
     LOCAL rcDeskTop AS RECT 'TYPE RECT: nLeft AS LONG, nTop AS LONG, nRight AS LONG, nBottom AS LONG
     LOCAL WinPla    AS WINDOWPLACEMENT
     
     FileName = LEFT$(ExeName, LEN(ExeName) - 3) & "ini" 'Set the ini filename to fit with the exe filename.
     FileNo = FREEFILE
     ERRCLEAR
     OPEN FileName FOR INPUT AS FileNo
     IF ERR THEN
       CheckBoxSet 1 + 2 + 4 + 8 + 16
       CONTROL SET OPTION  hDlg, %RadioExact, %RadioExact, %RadioOr
       RadioSetLabel %RadioExact
       EXIT FUNCTION  'Usually an error mean that the ini file is not created yet.
     END IF
     WHILE NOT EOF(FileNo)
       INPUT #FileNo, Buffer
       IF UCASE$(TRIM$(Buffer)) = "[DIALOG]" THEN 'Read the [Dialog] section.
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(UCASE$(Buffer))
            IF LEFT$(Buffer, 4) = "LEFT" THEN
              WinPla.rcNormalPosition.nLeft = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSEIF LEFT$(Buffer, 5) = "RIGHT" THEN
              WinPla.rcNormalPosition.nRight = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSEIF LEFT$(Buffer, 3) = "TOP" THEN
              WinPla.rcNormalPosition.nTop = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSEIF LEFT$(Buffer, 6) = "BOTTOM" THEN
              WinPla.rcNormalPosition.nBottom = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSEIF LEFT$(Buffer, 6) = "ZOOMED" THEN
              Zoomed = VAL(TRIM$(PARSE$(Buffer, "=", 2))) 'Get maximized status.
            ELSEIF LEFT$(Buffer, 12) = "CHECKBOXMARK" THEN
              CheckIt = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              SELECT CASE CheckIt
                CASE 0    : CheckBoxSet 1 + 2 + 4 + 8 + 16 + 32
                CASE 512  : CONTROL SET CHECK hDlg, %CheckAny, 1
                CASE 2048 : CONTROL SET CHECK hDlg, %CheckFile, 1
                CASE ELSE : CheckBoxSet CheckIt
              END SELECT
            ELSEIF LEFT$(Buffer, 11) = "CHECKBOXBAK" THEN
              CheckItBak = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSEIF LEFT$(Buffer, 5) = "RADIO" THEN
              RadioSet = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              IF RadioSet > 0 THEN
                CONTROL SET OPTION  hDlg, %RadioExact + RadioSet - 1, %RadioExact, %RadioOr
                RadioSetLabel %RadioExact + RadioSet - 1
              END IF
            ELSEIF LEFT$(Buffer, 5) = "WHOLE" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              CONTROL SET CHECK hDlg, %CheckWhole, Retval
            ELSEIF LEFT$(Buffer, 9) = "SUBFOLDER" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              CONTROL SET CHECK hDlg, %CheckSubDir, Retval
            ELSEIF LEFT$(Buffer, 8) = "WORDWRAP" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              IF Retval > 0 THEN
                SendMessage hEdm32, %EDM_SETWORDWRAP, 1, 0
                MENU SET STATE hMenu, BYCMD %PopWrap, %MF_CHECKED
              END IF
            ELSEIF LEFT$(Buffer, 15) = "SYNTAXHIGHLIGHT" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              IF Retval = 0 THEN
                SendMessage hEdm32, %EDM_SETSYNTAXONOFF, 0, 0
                MENU SET STATE hMenu, BYCMD %PopSyntax, %MF_UNCHECKED
              END IF
            ELSEIF LEFT$(Buffer, 8) = "GRIDLINE" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              IF Retval > 0 THEN
                SendMessage hEdm32, %EDM_SETGRID, 1, 0
                MENU SET STATE hMenu, BYCMD %PopGrid, %MF_CHECKED
              END IF
            ELSEIF LEFT$(Buffer, 9) = "BLANKLINE" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              IF Retval > 0 THEN
                MENU SET STATE hMenu, BYCMD %PopBlank, %MF_CHECKED
              END IF
            ELSEIF LEFT$(Buffer, 6) = "FILTER" THEN
              Retval = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              CheckBoxFilterset Retval
            ELSEIF LEFT$(Buffer, 5) = "QUICK" THEN
              Quick = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
       END IF
       IF UCASE$(TRIM$(Buffer)) = "[STRINGS]" THEN
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(Buffer)
            IF LEFT$(UCASE$(Buffer), 4) = "ITEM" THEN
              COMBOBOX ADD hDlg, %ComboSearch, MID$(Buffer, INSTR(Buffer, "=") + 2)
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
          COMBOBOX SELECT hDlg, %ComboSearch, 1
       END IF
       IF UCASE$(TRIM$(Buffer)) = "[FILEPATH]" THEN
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(Buffer)
            IF LEFT$(UCASE$(Buffer), 6) = "FOLDER" THEN
              COMBOBOX ADD hDlg, %ComboFolder, MID$(Buffer, INSTR(Buffer, "=") + 2)
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
          COMBOBOX SELECT hDlg, %ComboFolder, 1
       END IF
       IF UCASE$(TRIM$(Buffer)) = "[FIND]" THEN
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(Buffer)
            IF LEFT$(UCASE$(Buffer), 6) = "TARGET" THEN
              COMBOBOX ADD hDlg, %ComboFind,  MID$(Buffer, INSTR(Buffer, "=") + 2)
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
          COMBOBOX SELECT hDlg, %ComboFind, 1
       END IF
       IF UCASE$(TRIM$(Buffer)) = "[EDITOR]" THEN
          Retval = 0
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(Buffer)
            IF INSTR(Buffer, "=") THEN
              INCR RETVAL
              REDIM PRESERVE Editor(0 TO RETVAL)
              Editor(Retval) = TRIM$(PARSE$(Buffer, "=", 1)) & $TAB & TRIM$(PARSE$(Buffer, "=", 2))
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
     
       END IF
       IF UCASE$(TRIM$(Buffer)) = "[PRESET]" THEN
          DO
            INPUT #FileNo, Buffer
            Buffer = TRIM$(Buffer)
     
            IF LEFT$(UCASE$(Buffer), 10) = "PRESETLAST" THEN
              PresetLast = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              FontMakeBold(PresetLast, 2)
            ELSEIF LEFT$(UCASE$(Buffer), 6) = "FOLDER" THEN
              Retval = VAL(MID$(Buffer, 7, 1))
              IF Retval > 0 AND Retval < 5 THEN
                PresetFolder(Retval) = TRIM$(PARSE$(Buffer, "=", 2))
              END IF
            ELSEIF LEFT$(UCASE$(Buffer), 6) = "SEARCH" THEN
              Retval = VAL(MID$(Buffer, 7, 1))
              IF Retval > 0 AND Retval < 5 THEN
                PresetCheckBox(Retval) = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              END IF
            ELSEIF LEFT$(UCASE$(Buffer), 4) = "FILE" THEN
              Retval = VAL(MID$(Buffer, 5, 1))
              IF Retval > 0 AND Retval < 5 THEN
                PresetCheckBoxFilter(Retval) = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              END IF
            ELSEIF LEFT$(UCASE$(Buffer), 6) = "SUBDIR" THEN
              Retval = VAL(MID$(Buffer, 7, 1))
              IF Retval > 0 AND Retval < 5 THEN
                PresetCheckBoxSubDir(Retval) = VAL(TRIM$(PARSE$(Buffer, "=", 2)))
              END IF
            ELSE
              IF LEFT$(Buffer, 1) = "[" THEN EXIT DO 'Beginning of a new section, so exit.
            END IF
          LOOP UNTIL EOF(FileNo)
       END IF
     
     WEND
     CLOSE FileNo
     
     SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(rcDesktop), 0 'Desktop's real size, thanks to Borje
     IF Zoomed THEN WinPla.showCmd = %SW_SHOWMAXIMIZED
     
     'Make sure dialog is not horizontally oversized.
     IF WinPla.rcNormalPosition.nRight - WinPla.rcNormalPosition.nLeft > rcDesktop.nRight THEN
       WinPla.rcNormalPosition.nLeft  = 0
       WinPla.rcNormalPosition.nRight = rcDesktop.nRight
     END IF
     
     'Make sure dialog is not vertically oversized.
     IF WinPla.rcNormalPosition.nBottom - WinPla.rcNormalPosition.nTop > rcDesktop.nBottom THEN
       WinPla.rcNormalPosition.nTop    = 0
       WinPla.rcNormalPosition.nBottom = rcDesktop.nBottom
     END IF
     
     'Make sure left side of dialog is visible.
     IF WinPla.rcNormalPosition.nLeft < 0 THEN
       WinPla.rcNormalPosition.nRight = WinPla.rcNormalPosition.nRight - WinPla.rcNormalPosition.nLeft
       WinPla.rcNormalPosition.nLeft = 0
     END IF
     
     'Make sure right side of dialog is visible.
     IF WinPla.rcNormalPosition.nRight > rcDesktop.nRight THEN
       WinPla.rcNormalPosition.nLeft = WinPla.rcNormalPosition.nLeft - (WinPla.rcNormalPosition.nRight - rcDesktop.nRight)
       WinPla.rcNormalPosition.nRight = rcDesktop.nRight
     END IF
     
     'Make sure top side of dialog is visible.
     IF WinPla.rcNormalPosition.nTop < 0 THEN
       WinPla.rcNormalPosition.nBottom = WinPla.rcNormalPosition.nBottom - WinPla.rcNormalPosition.nTop
       WinPla.rcNormalPosition.nTop = 0
     END IF
     
     'Make sure bottom side of dialog is visible.
     IF WinPla.rcNormalPosition.nBottom > rcDesktop.nBottom THEN
       WinPla.rcNormalPosition.nTop = WinPla.rcNormalPosition.nTop - (WinPla.rcNormalPosition.nBottom - rcDesktop.nBottom)
       WinPla.rcNormalPosition.nBottom = rcDesktop.nBottom
     END IF
     
     WinPla.Length = SIZEOF(WinPla)
     SetWindowPlacement hDlg, WinPla
     ControlSetSize
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION SpaceShrink(sString AS STRING) AS STRING
     LOCAL Buffer AS STRING
     
     Buffer = sString
     DO
       IF INSTR(Buffer, "  ") = 0 THEN EXIT DO
       REPLACE "  " WITH " " IN Buffer
     LOOP
     
     FUNCTION = Buffer
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ControlEnable(Action AS LONG) AS LONG
     
     IF Action THEN
       CONTROL ENABLE hDlg, %ComboFolder
       CONTROL ENABLE hDlg, %ComboSearch
       CONTROL ENABLE hDlg, %RadioExact
       CONTROL ENABLE hDlg, %RadioAnd
       CONTROL ENABLE hDlg, %RadioOr
       CONTROL ENABLE hDlg, %CheckWhole
       CONTROL ENABLE hDlg, %LabelExactAndOr
       CONTROL ENABLE hDlg, %ButtonFolder
       CONTROL ENABLE hDlg, %ButtonSet
       CONTROL ENABLE hDlg, %CheckConst
       CONTROL ENABLE hDlg, %CheckUnion
       CONTROL ENABLE hDlg, %CheckType
       CONTROL ENABLE hDlg, %CheckMacro
       CONTROL ENABLE hDlg, %CheckFunc
       CONTROL ENABLE hDlg, %CheckSub
       CONTROL ENABLE hDlg, %CheckElse
       CONTROL ENABLE hDlg, %CheckAny
       CONTROL ENABLE hDlg, %CheckFile
       CONTROL ENABLE hDlg, %CheckInside
       CONTROL ENABLE hDlg, %LabelInside
       CONTROL ENABLE hDlg, %CheckInc
       CONTROL ENABLE hDlg, %CheckBas
       CONTROL ENABLE hDlg, %CheckSubDir
       CONTROL ENABLE hDlg, %UpdownFN
       CONTROL ENABLE hDlg, %ButtonQuick
       CONTROL ENABLE hDlg, %ButtonPreset1
       CONTROL ENABLE hDlg, %ButtonPreset2
       CONTROL ENABLE hDlg, %ButtonPreset3
       CONTROL ENABLE hDlg, %ButtonPreset4
       CONTROL ENABLE hDlg, %LabelPreset
     ELSE
       CONTROL DISABLE hDlg, %ComboFolder
       CONTROL DISABLE hDlg, %ComboSearch
       CONTROL DISABLE hDlg, %RadioExact
       CONTROL DISABLE hDlg, %RadioAnd
       CONTROL DISABLE hDlg, %RadioOr
       CONTROL DISABLE hDlg, %CheckWhole
       CONTROL DISABLE hDlg, %LabelExactAndOr
       CONTROL DISABLE hDlg, %ButtonFolder
       CONTROL DISABLE hDlg, %ButtonSet
       CONTROL DISABLE hDlg, %CheckConst
       CONTROL DISABLE hDlg, %CheckUnion
       CONTROL DISABLE hDlg, %CheckType
       CONTROL DISABLE hDlg, %CheckMacro
       CONTROL DISABLE hDlg, %CheckFunc
       CONTROL DISABLE hDlg, %CheckSub
       CONTROL DISABLE hDlg, %CheckElse
       CONTROL DISABLE hDlg, %CheckAny
       CONTROL DISABLE hDlg, %CheckFile
       CONTROL DISABLE hDlg, %CheckInside
       CONTROL DISABLE hDlg, %LabelInside
       CONTROL DISABLE hDlg, %CheckInc
       CONTROL DISABLE hDlg, %CheckBas
       CONTROL DISABLE hDlg, %CheckSubDir
       CONTROL DISABLE hDlg, %UpdownFN
       CONTROL DISABLE hDlg, %ButtonQuick
       CONTROL DISABLE hDlg, %ButtonPreset1
       CONTROL DISABLE hDlg, %ButtonPreset2
       CONTROL DISABLE hDlg, %ButtonPreset3
       CONTROL DISABLE hDlg, %ButtonPreset4
       CONTROL DISABLE hDlg, %LabelPreset
     END IF
     
     DIALOG REDRAW hDlg
     
    END FUNCTION
    '______________________________________________________________________________
     
    SUB SearchFiles(hDlg AS LONG, sFindArray() AS STRING, FindAction AS LONG)
     LOCAL sFile             AS STRING
     LOCAL sBuffer           AS STRING
     LOCAL sCheck            AS STRING
     LOCAL sLine             AS STRING
     LOCAL Space4            AS STRING
     LOCAL Extention         AS STRING
     LOCAL FileNameHeader    AS STRING
     LOCAL LineFeed          AS STRING
     LOCAL sLineNoTextNoRem  AS STRING
     LOCAL TypeFile          AS LONG
     LOCAL CheckIt           AS LONG
     LOCAL hMenuState        AS LONG
     LOCAL FindProceed       AS LONG
     LOCAL FoundCount        AS LONG
     LOCAL ItemCount         AS LONG
     LOCAL ItemCountFile     AS LONG
     LOCAL Counter           AS LONG
     LOCAL FileCount         AS LONG
     LOCAL FileWithData      AS LONG
     LOCAL FileNo            AS LONG
     LOCAL FolderCount       AS LONG
     LOCAL FolderCounter     AS LONG
     LOCAL Retval            AS LONG
     LOCAL Filter            AS LONG
     LOCAL FileRead          AS LONG
     LOCAL MultiLine         AS LONG
     LOCAL CharPos1          AS LONG
     LOCAL CharPos2          AS LONG
     LOCAL LineCount         AS DWORD
     LOCAL LineCurrent       AS DWORD
     LOCAL MsgTag            AS TagMsg
     DIM   Folder(0 TO 0)    AS STRING
     LOCAL FindProceedFile   AS LONG
     LOCAL sOutFile          AS STRING
     LOCAL PrecedingCharPos  AS LONG
     LOCAL SubsequentCharPos AS LONG
     LOCAL CharValue         AS LONG
     LOCAL Whole             AS LONG
     
     DIM   AndFileFound(1 TO UBOUND(sFindArray())) AS LONG
     
     ON ERROR RESUME NEXT
     Space4 = SPACE$(4)
     LineFeed = $CRLF
     MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
     IF ISTRUE(Retval AND %MF_CHECKED) THEN LineFeed = LineFeed & $CRLF
     SearchCancel = 0
     CONTROL GET CHECK hDlg, %CheckWhole TO Whole
     CONTROL SET TEXT hDlg, %ButtonSearch, $Stop
     CONTROL DISABLE hDlg, %ButtonExit
     CONTROL DISABLE hDlg, %ButtonView
     CONTROL DISABLE hDlg, %ButtonOption
     CONTROL DISABLE hDlg, %ButtonHint
     CONTROL DISABLE hDlg, %ButtonFindNext
     CONTROL DISABLE hDlg, %ButtonFindPrev
     CONTROL DISABLE hDlg, %ComboFind
     CONTROL DISABLE hDlg, %LabelFind
     CONTROL DISABLE hDlg, %UpDownFind
     CONTROL DISABLE hDlg, %LabelLineCol
     
     ControlEnable 0
     hMenuState = GetSystemMenu(hDlg, 0)
     EnableMenuItem hMenuState, %SC_CLOSE, %MF_BYCOMMAND OR %MF_GRAYED
     SendMessage hEdm32, %EDM_DELETE, 1, 1 'clear text
     SetWindowText hDlg, $AppName & " - Searching..."
     CONTROL SET TEXT hDlg, %StatusBar, " Searching..." & Folder(FolderCounter)
     
     CheckIt = CheckBoxGet
     sOut = ""
     
     FolderCount = FolderGetArray(Folder())
     
     Filter = CheckBoxFilterGet
     IF Filter = 0 THEN Filter = 3 : CheckBoxFilterSet Filter
     
     FOR FolderCounter = 1 TO FolderCount
       sFile = DIR$(Folder(FolderCounter) & "*.*", 39)
       DO
         IF sFile = "" THEN EXIT DO
         Extention = LCASE$(MID$(sFile, INSTR(-1, SFile, ".") + 1))
         FileRead = 0
         TypeFile = 0
         IF ISTRUE(Filter AND 1) THEN
           IF Extention = "inc" OR Extention = "h" THEN FileRead = 1
           IF Extention = "h" THEN TypeFile = 1
         END IF
         IF ISTRUE(Filter AND 2) THEN
           IF Extention = "bas" OR Extention = "bi" OR Extention = "rc" THEN FileRead = 1
           IF Extention = "rc" THEN TypeFile = 1
         END IF
     
         IF FileRead THEN
           INCR FileCount
           SetWindowText hDlg, $AppName & " - " & FORMAT$(ItemCount) _
           & " found in " & FORMAT$(FileWithData) & " files, " & FORMAT$(FileCount) & " files searched"
           CONTROL SET TEXT hDlg, %StatusBar, " Searching - " & Folder(FolderCounter) & sFile
           FileNameHeader = "'>>> " & UCASE$(Folder(FolderCounter) & sFile) & " " _
                            & STRING$(95 - LEN(Folder(FolderCounter) & sFile) , "<") & LineFeed
           IF LEN(sOut) THEN FileNameHeader = $CRLF & FileNameHeader
           FileNo = FREEFILE
           OPEN Folder(FolderCounter) & sFile FOR INPUT AS FileNo LEN = 65536
           FILESCAN #FileNo, RECORDS TO LineCount
           REDIM TextLine(1 TO LineCount) AS STRING
           LINE INPUT #FileNo, TextLine()
           CLOSE #FileNo
           LineCurrent = 0
     
           DO UNTIL LineCurrent >= LineCount
     
             DO WHILE PeekMessage(MsgTag, 0, 0, 0, %PM_NOREMOVE)
               DIALOG DOEVENTS
             LOOP
     
             IF SearchCancel THEN EXIT, EXIT, EXIT
             IF ItemCount >= 5000 THEN
               EXIT, EXIT, EXIT
             END IF
             INCR LineCurrent
             sBuffer = TextLine(LineCurrent)
             sBuffer = LTRIM$(sBuffer)
             sCheck = LCASE$(sBuffer)
             sCheck = SpaceShrink(sCheck)
     
             IF ISTRUE(CheckIt AND 2048) THEN '//File
               GOSUB MultiLineMerge
               GOSUB StringCheck
               ITERATE DO
             END IF
     
             IF ISTRUE(CheckIt AND 512) THEN '//Any
               GOSUB MultiLineMerge
               GOSUB StringCheck
               ITERATE DO
             END IF

    Comment


    • #3
      Code:
               IF INSTR(LEFT$(sCheck, 1), ANY "%&[email protected]$") THEN '// Const
                 IF ISTRUE(CheckIt AND 1) THEN
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF LEFT$(sCheck, 6) = "union " THEN '// Union
                 DO
                   INCR LineCurrent
                   sLine = TextLine(LineCurrent)
                   sLine = LTRIM$(sLine)
                   IF LCASE$(LEFT$(sLine, 9)) = "end union" THEN
                     sBuffer = sBuffer & $CRLF & sLine
                     EXIT DO
                   END IF
                   sBuffer = sBuffer & $CRLF & Space4 & sLine
                 LOOP UNTIL LineCurrent >= LineCount
                 IF ISTRUE(CheckIt AND 2) THEN 'Union
                   IF ISTRUE(CheckIt AND 1024) THEN sCheck = LCASE$(sBuffer) 'Inside
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF LEFT$(sCheck, 5) = "type " THEN '// Type
                 DO
                   INCR LineCurrent
                   sLine = TextLine(LineCurrent)
                   sLine = LTRIM$(sLine)
                   IF LCASE$(LEFT$(sLine, 8)) = "end type" THEN
                     sBuffer = sBuffer & $CRLF & sLine
                     EXIT DO
                   END IF
                   sBuffer = sBuffer & $CRLF & Space4 & sLine
                 LOOP UNTIL LineCurrent >= LineCount
                 IF ISTRUE(CheckIt AND 4) THEN 'Type
                   IF ISTRUE(CheckIt AND 1024) THEN sCheck = LCASE$(sBuffer) 'Inside
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF LEFT$(sCheck, 6) = "macro " THEN '// Macro
                 IF INSTR(sBuffer, "=") = 0 THEN
                   DO
                     INCR LineCurrent
                     sLine = TextLine(LineCurrent)
                     sLine = LTRIM$(sLine)
                     IF LCASE$(LEFT$(sLine, 9)) = "end macro" THEN
                       sBuffer = sBuffer & $CRLF & sLine
                       EXIT DO
                     END IF
                     sBuffer = sBuffer & $CRLF & Space4 & sLine
                   LOOP UNTIL LineCurrent >= LineCount
                 END IF
                 IF ISTRUE(CheckIt AND 8) THEN 'Macro
                   IF ISTRUE(CheckIt AND 1024) THEN sCheck = LCASE$(sBuffer) 'Inside
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF LEFT$(sCheck, 17) = "declare function " OR _
                  LEFT$(sCheck, 9)  = "function " OR _
                  LEFT$(sCheck, 16) = "static function " OR _
                  LEFT$(sCheck, 18) = "callback function "  THEN '// Func
                 GOSUB MultiLineMerge
                 IF ISTRUE(CheckIt AND 16) THEN 'Function
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF LEFT$(sCheck, 12) = "declare sub " OR _
                  LEFT$(sCheck, 4)  = "sub " OR _
                  LEFT$(sCheck, 11) = "static sub " THEN '// Sub
                 GOSUB MultiLineMerge
                 IF ISTRUE(CheckIt AND 32) THEN 'Sub
                   GOSUB StringCheck
                 END IF
                 ITERATE DO
               END IF
       
               IF ISTRUE(CheckIt AND 128) THEN '// Else
                 GOSUB MultiLineMerge
                 GOSUB StringCheck
               END IF
               ITERATE DO
       
             LOOP
       
             IF ISTRUE(CheckIt AND 2048) THEN '//File, one file completed, check if every word was found
               IF FindAction = %FindAnd THEN
                 Retval = 0
                 FOR Counter = 1 TO UBOUND(AndFileFound())
                   IF ISTRUE(AndFileFound(Counter)) THEN INCR Retval ': INCR ItemCount
                   AndFileFound(Counter) = %False 'Reset for next file read
                 NEXT
                 IF Retval = UBOUND(sFindArray()) THEN
                   sOut = sOut & sOutFile
                   ItemCount = ItemCount + ItemCountFile
                 ELSE
                   IF Retval > 0 THEN Decr FileWithData
                 END IF
                 sOutFile = ""
                 ItemCountFile = 0
               END IF
             END IF
       
           ELSE 'FileRead
             IF FileCount = 0 THEN
               SetWindowText hDlg, $AppName & " - " & Folder(FolderCounter) & sFile
               CONTROL SET TEXT hDlg, %StatusBar, " Searching - " & Folder(FolderCounter)
             END IF
           END IF 'FileRead
       
           sFile = DIR$
         LOOP
       NEXT
       
       IF FileCount = 0 THEN
         sOut = "' Sorry, no valid file found in folder " & FolderPath & " !"
         CONTROL SET TEXT hDlg, %StatusBar, $SPC & MID$(sOut, 3)
       ELSE
         IF sOut = "" THEN
           sOut = "' Sorry, nothing found in " & FORMAT$(FileCount) & " files."
           CONTROL SET TEXT hDlg, %StatusBar, $SPC & MID$(sOut, 3)
         ELSE
           IF ItemCount >= 5000 THEN
             SetWindowText hDlg, $AppName & " - " & FORMAT$(ItemCount) _
             & " found in " & FORMAT$(FileWithData) & " files, " & FORMAT$(FileCount) & " files searched" _
             & " - 5000 limit reached"
           END IF
           CONTROL SET TEXT hDlg, %StatusBar, " Double-click to see file, or right-click for options."
         END IF
       END IF
       
       IF SearchCancel THEN
         DIALOG GET TEXT hDlg TO sBuffer
         DIALOG SET TEXT hDlg, sBuffer & " - Search stopped"
       END IF
       
       edmSetText hEdm32, sOut
       CONTROL SET TEXT hDlg, %ButtonSearch, $Search
       ControlEnable 1
       CONTROL ENABLE hDlg, %ButtonExit
       CONTROL ENABLE hDlg, %ButtonView
       CONTROL ENABLE hDlg, %ButtonOption
       CONTROL ENABLE hDlg, %ButtonHint
       CONTROL ENABLE hDlg, %ButtonFindNext
       CONTROL ENABLE hDlg, %ButtonFindPrev
       CONTROL ENABLE hDlg, %ComboFind
       CONTROL SHOW STATE hDlg, %LabelFind, %SW_HIDE
       CONTROL ENABLE hDlg, %LabelFind
       CONTROL SHOW STATE hDlg, %LabelFind, %SW_SHOWNORMAL
       CONTROL ENABLE hDlg, %UpDownFind
       EnableMenuItem hMenuState, %SC_CLOSE, %MF_BYCOMMAND OR %MF_ENABLED
       CONTROL SHOW STATE hDlg, %LabelLineCol, %SW_HIDE
       CONTROL ENABLE hDlg, %LabelLineCol
       CONTROL SHOW STATE hDlg, %LabelLineCol, %SW_SHOWNORMAL
       EXIT SUB
       '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       StringCheck:
         FoundCount      = 0
         FindProceed     = %False
         FindProceedFile = %False
         FOR Counter = 1 TO UBOUND(sFindArray())
           IF INSTR(sCheck, sFindArray(Counter)) > 0 THEN
       
             IF Whole THEN '//Whole word
               PrecedingCharPos = INSTR(sCheck, sFindArray(Counter)) - 1
               SubsequentCharPos = PrecedingCharPos + LEN(sFindArray(Counter)) + 1
               IF PrecedingCharPos THEN
                 CharValue = ASC(MID$(sCheck, PrecedingCharPos, 1))
                 IF ISTRUE(CharValue >= 97) AND ISTRUE(CharValue <= 122) THEN 'a-z
                   ITERATE FOR 'Not a whole word
                 END IF
               END IF
               IF SubsequentCharPos >= LEN(sFindArray(Counter)) THEN
                 CharValue = ASC(MID$(sCheck, SubsequentCharPos, 1))
                 IF ISTRUE(CharValue >= 97) AND ISTRUE(CharValue <= 122) THEN 'a-z
                   ITERATE FOR 'Not a whole word
                 END IF
               END IF
             END IF
       
             INCR FoundCount
             IF ISTRUE(CheckIt AND 2048) THEN '//File
               IF FindAction = %FindAnd THEN
                 AndFileFound(Counter) = %True 'For And+File option
                 FindProceedFile = %True
                 INCR ItemCountFile
               END IF
             END IF
           END IF
         NEXT
         SELECT CASE FindAction
           CASE %FindExact : IF FoundCount > 0 THEN FindProceed = %True : INCR ItemCount
           CASE %FindOr    : IF FoundCount > 0 THEN FindProceed = %True : INCR ItemCount
           CASE %FindAnd
             IF ISFALSE(CheckIt AND 2048) THEN 'File
               IF FoundCount = UBOUND(sFindArray()) THEN FindProceed = %True : INCR ItemCount
             END IF
         END SELECT
         IF FindProceed THEN
           sOut = sOut & FileNameHeader & sBuffer & LineFeed
           IF LEN(FileNameHeader) THEN INCR FileWithData
           FileNameHeader = ""
         END IF
         IF FindProceedFile THEN
           sOutFile = sOutFile & FileNameHeader & sBuffer & LineFeed
           IF LEN(FileNameHeader) THEN INCR FileWithData
           FileNameHeader = ""
         END IF
       
       RETURN
       '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       MultiLineMerge:
        'This sub analyse if the line is a valid multi-line statement,
        'excluding lines like...
        'S$ = "123" '_
        'witch is ending with an underscore but is not a multi-line statement.
         IF TypeFile = 1 THEN RETURN 'Not a basic file, h or rc
         sLine = sCheck
         DO
           MultiLine = %False
           IF INSTR(sLine, "_") THEN
             sLineNoTextNoRem = LCASE$(sLine)
       
             'First remove text between double quote, it might contain <_>, <'> and <rem>
             IF INSTR(sLineNoTextNoRem, $DQ) THEN
               DO
                 CharPos1 = INSTR(sLineNoTextNoRem, $DQ)
                 IF CharPos1 THEN
                   CharPos2 = INSTR(CharPos1 + 1, sLineNoTextNoRem, $DQ)
                   IF CharPos2 > CharPos1 THEN
                     sLineNoTextNoRem = LEFT$(sLineNoTextNoRem, CharPos1 - 1) _
                                       & MID$(sLineNoTextNoRem, CharPos2 + 1)
                   END IF
                 ELSE
                   EXIT DO
                 END IF
               LOOP UNTIL CharPos2 = 0
             END IF
       
             'Now, remove text after a remark (' or REM) that might contain underscore.
             CharPos1 = INSTR(sLineNoTextNoRem, "'")
             IF CharPos1 THEN sLineNoTextNoRem = LEFT$(sLineNoTextNoRem, CharPos1 - 1)
             CharPos1 = INSTR(sLineNoTextNoRem, " rem ")
             IF CharPos1 THEN sLineNoTextNoRem = LEFT$(sLineNoTextNoRem, CharPos1 - 1)
             IF RIGHT$(sLineNoTextNoRem, 4) = " rem" THEN
               sLineNoTextNoRem = LEFT$(sLineNoTextNoRem, LEN(sLineNoTextNoRem) - 1)
             END IF
       
             'Now, keep the last statement if multi-statements on a single line separated with semi-column.
             CharPos1 = INSTR(- 1, sLineNoTextNoRem, ":")
             IF CharPos1 THEN sLineNoTextNoRem = MID$(sLineNoTextNoRem, CharPos1 + 1)
       
             IF INSTR(sLineNoTextNoRem, " _") THEN MultiLine = %True
             IF INSTR(sLineNoTextNoRem, ",_") THEN MultiLine = %True
             IF INSTR(sLineNoTextNoRem, "(_") THEN MultiLine = %True
             IF LCASE$(LEFT$(sLineNoTextNoRem, 5)) = "data " THEN MultiLine = %False
       
             IF MultiLine THEN
               INCR LineCurrent
               IF LineCurrent <= LineCount THEN
                 sLine = TextLine(LineCurrent)
                 sLine = LTRIM$(sLine)
                 sBuffer = sBuffer & $CRLF & Space4 & sLine
                 sCheck = LCASE$(sBuffer)
                 sCheck = SpaceShrink(sCheck)
               END IF
             ELSE
               EXIT
             END IF
           ELSE
             EXIT DO 'No underscore in line, so, exit
           END IF
         LOOP UNTIL LineCurrent >= LineCount
       RETURN
       
      END SUB
      '______________________________________________________________________________
       
      FUNCTION FileNameGet() AS STRING
       LOCAL  Counter  AS LONG
       LOCAL  LineNum  AS LONG
       LOCAL  FileName AS STRING
       LOCAL  Buffer   AS STRING
       
       DIALOG GET TEXT hDlg TO Buffer
       IF INSTR(Buffer, "\") THEN
          FileName = MID$(Buffer, INSTR(Buffer, " - ")+ 3)
       ELSE
         LineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0)
         FOR Counter = LineNum TO 0 STEP - 1
           Buffer = edmTxtGetLine(hEdm32, Counter)
           IF LEFT$(Buffer, 5) = "'>>> " THEN
             FileName = MID$(Buffer, 6)
             IF INSTR(FileName, " <") THEN
               FileName = LEFT$(FileName, INSTR(FileName, " <") - 1)
             END IF
             EXIT FOR
           END IF
         NEXT Counter
       END IF
       FUNCTION = FileName
       
      END FUNCTION
      '______________________________________________________________________________
       
      FUNCTION FileNameSet() AS STRING
       LOCAL Buffer AS STRING
       LOCAL Pos1   AS LONG
       LOCAL Pos2   AS LONG
       
       Buffer = ""
       Pos1 = 1
       DO
         Pos1 = INSTR(Pos1, sOut, "'>>> ")
         IF Pos1 THEN
           Pos2 = INSTR(Pos1, sOut, $CRLF)
           IF Pos2 THEN
             Buffer = Buffer & MID$(sOut, Pos1, Pos2 - Pos1) & $CRLF
             Pos1 = Pos2 + 1
           END IF
         ELSE
           EXIT DO
         END IF
       LOOP
       FUNCTION = Buffer
       
      END FUNCTION
      '______________________________________________________________________________
       
      CALLBACK FUNCTION PBMainProc()
       LOCAL  sTmp           AS STRING
       LOCAL  Buffer         AS STRING
       LOCAL  TextLine       AS STRING
       LOCAL  FileName       AS STRING
       LOCAL  Folder         AS STRING
       DIM    sTmpArray()    AS STRING
       STATIC FileUnWrapped  AS STRING
       STATIC DialogCaption  AS STRING
       STATIC sFindOld       AS STRING
       STATIC QuickTextLine  AS STRING
       STATIC FindPrev       AS STRING
       STATIC SearchPrev     AS STRING
       LOCAL  hMenuState     AS LONG
       LOCAL  cbCount        AS LONG
       LOCAL  Counter        AS LONG
       LOCAL  FindAction     AS LONG
       LOCAL  Retval         AS LONG
       LOCAL  LineNum        AS LONG
       STATIC LineNumSearch  AS LONG
       STATIC LineTopSearch  AS LONG
       LOCAL  LineLengh      AS LONG
       LOCAL  EdmLineCurrent AS LONG
       LOCAL  EdmLineCount   AS LONG
       LOCAL  FileNo         AS LONG
       LOCAL  NextPrev       AS LONG
       STATIC hFocus         AS LONG
       STATIC ViewFile       AS LONG
       STATIC hBmp           AS LONG
       LOCAL  hBmpDC         AS LONG
       STATIC FindPosFirst   AS LONG
       STATIC QuickTopLine   AS LONG
       STATIC QuickLineNum   AS LONG
       STATIC FullTopLine    AS LONG
       STATIC FullLineNum    AS LONG
       LOCAL  Pos1           AS LONG
       LOCAL  Pos2           AS LONG
       LOCAL  hHandle        AS LONG
       LOCAL  pt             AS POINTAPI
       LOCAL  NmhdrPtr       AS NMHDR PTR
       LOCAL  NmhdrMsg       AS NMHDR
       LOCAL  MinMaxInfoPtr  AS MINMAXINFO PTR
       STATIC rcDeskTop      AS RECT 'TYPE RECT: nLeft AS LONG, nTop AS LONG, nRight AS LONG, nBottom AS LONG
       LOCAL  zFolder        AS ASCIIZ * %MAX_PATH
       LOCAL  zString        AS ASCIIZ * %MAX_PATH
       
       SELECT CASE CBMSG
         CASE %WM_INITDIALOG
       
           CONTROL HANDLE hDlg, %ComboSearch TO hCbSearch
           CONTROL HANDLE hDlg, %ComboFolder TO hCbFolder
       
           DIALOG POST hDlg, %WM_SIZE, 0, 0 'For Statusbar
           CONTROL SET TEXT hDlg, %StatusBar, $SPC & $AppName & $SPC & $Appver _
                & " - Search engine for PowerBASIC code - Use right-click for options."
       
           edmSetFontEditor hEdm32, "Courier New", 9, 0, 0, 0
           CALL SendMessage(hEdm32, %EDM_SHOWSCROLLINFO, 1, 1)
       
           PopEditorAdd
       
           'Background
           SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(rcDesktop), 0
           DIALOG UNITS CBHNDL, rcDesktop.nRight, rcDesktop.nBottom TO PIXELS rcDesktop.nRight, rcDesktop.nBottom
           hBmp = LoadImage(GetModuleHandle(BYVAL %Null), "BackGround", %IMAGE_BITMAP, rcDesktop.nRight, rcDesktop.nBottom, %LR_DEFAULTSIZE)
           IF Quick = 1 THEN
             CONTROL SET TEXT hDlg, %ButtonQuick, "&Quest"
             MENU SET STATE hMenu, BYCMD %PopBlank, %MF_GRAYED OR Retval
             MENU SET STATE hMenu, BYCMD %PopWrap, %MF_GRAYED OR Retval
           END IF
       
           CONTROL GET TEXT hDlg, %ComboFind TO FindPrev
           CONTROL GET TEXT hDlg, %ComboSearch TO SearchPrev
           IF LEN(Command$) THEN CONTROL SET TEXT hDlg, %ComboSearch, Command$
           FontMakeBold(PresetLast, 0) 'Init
           FontMakeBold(PresetLast, 2) 'Bold
       
           CALL SendMessage(hEdm32, %EDM_SETCOLORPAGE, RGB(250, 250, 255), 0)
           CALL SendMessage(hEdm32, %EDM_SETCOLORTXTBK, RGB(250, 250, 255), 0)
       
       
         CASE %WM_ERASEBKGND
           hBmpDC = CreateCompatibleDC(CBWPARAM)
           SelectObject hBmpDC, hBmp
           BitBlt CBWPARAM, 0, 0, rcDesktop.nRight, 130, hBmpDC, 0, 0, %SRCCOPY
           DeleteDC hBmpDC
           FUNCTION = 1
       
         CASE %WM_DESTROY
           DeleteObject hBmp
           FontMakeBold(PresetLast, 3) 'Delete font
       
         CASE %EDM_SETINFO 'trap notification from editor control, and get/show info in labels
           CONTROL SHOW STATE hDlg, %LabelLineCol, %SW_HIDE
           CONTROL SET TEXT hDlg, %LabelLineCol, _
                "Line " & FORMAT$(SendMessage(hEdm32, %EDM_GETCARETY, 0, 0) + 1, "#,") & _ '$CRLF & _
                ", Column " & FORMAT$(SendMessage(hEdm32, %EDM_GETCARETX, 0, 0) + 1, "#,") & _ '$CRLF & _
                ", SelLen " & FORMAT$(SendMessage(hEdm32, %EDM_GETSELLENGTH, 0, 0), "#,")
           CONTROL SHOW STATE hDlg, %LabelLineCol, %SW_SHOWNORMAL
       
         CASE %WM_NOTIFY
           NmhdrPtr = CBLPARAM
       
           IF @NmhdrPtr.hWndFrom = hEdm32 AND @NmhdrPtr.code = %NM_FIRST - 5 THEN 'RCLICK
             CONTROL GET TEXT hDlg, %ButtonSearch TO Buffer
             IF Buffer = $Stop THEN '&Stop if search is in progress
               Beep
               ShakeDialog hDlg
             ELSE '&Search
               GetCursorPos pt
               TrackPopupMenu hmenu, %TPM_LEFTALIGN OR %TPM_RIGHTBUTTON, pt.x, pt.y, BYVAL 0, CBHNDL, BYVAL 0
             END IF
           END IF
       
           IF @NmhdrPtr.hWndFrom = hEdm32 AND @NmhdrPtr.code = %NM_FIRST - 2 THEN 'Click down
             IF ViewFile = 0 THEN
               FileName = FileNameGet
               IF LEN(FileName) THEN
                 CONTROL SET TEXT hDlg, %StatusBar, " Double-click to see " & FileName & _
                                    " or right-click for options."
               END IF
               CALL SendMessage(hEdm32, %EDM_RESETBMARKSALL, 0, 0)
               CALL SendMessage(hEdm32, %EDM_SETBMCOLOR, RGB(255, 255, 0), 1)
               LineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0)
               edmBookMarkSet hEdm32, LineNum, 1  'Set bookmark
               SendMessage hEdm32, %EDM_REFRESH, 0, -1 'Redraw control
             END IF
           END IF
       
           IF @NmhdrPtr.hWndFrom = hEdm32 AND @NmhdrPtr.code = %NM_FIRST - 3 THEN 'Double-Click
             IF ViewFile = 0 THEN 'Switch from View-Result to View-File
               FileName = FileNameGet
               LineTopSearch = SendMessage(hEdm32, %EDM_GETTOPLINE, 0, 0)
               LineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0) '+ 1
               LineNumSearch = LineNum + 1
               FOR Counter = LineNum TO 0 STEP - 1
                 TextLine = edmTxtGetLine(hEdm32, Counter)
                 IF LEN(TRIM$(TextLine)) THEN EXIT FOR
               NEXT
       
               IF LEN(FileName) THEN
                 FindPosFirst = -1
                 ViewFile = 1
                 MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
                 Retval = Retval AND %MF_CHECKED
                 MENU SET STATE hMenu, BYCMD %PopBlank, %MF_GRAYED OR Retval
                 IF Quick THEN
                   MENU GET STATE hMenu, BYCMD %PopWrap TO Retval
                   Retval = Retval AND %MF_CHECKED
                   MENU SET STATE hMenu, BYCMD %PopWrap, Retval
                 END IF
                 DIALOG GET TEXT hDlg TO DialogCaption
                 DIALOG SET TEXT hDlg, $AppName & " - " & FileName
                 CONTROL SET TEXT hDlg, %StatusBar, _
                                 " Double-click to return to search result and leave " & _
                                 FileName & " or right-click for options."
                 CONTROL SET TEXT CBHNDL, %ButtonView, "R&esult"
                 CONTROL DISABLE hDlg, %ButtonSearch
                 ControlEnable 0
                 CONTROL ENABLE hDlg, %ComboFunc
                 CALL SendMessage(hEdm32, %EDM_SETCOLORPAGE, RGB(255, 255, 240), 1)
                 CALL SendMessage(hEdm32, %EDM_SETCOLORTXTBK, RGB(255, 255, 240), 1)
                 FileNo = FREEFILE
                 OPEN FileName FOR BINARY AS FileNo
                 GET$ FileNo, LOF(FileNo), FileUnWrapped
                 CLOSE FileNo
                 SLEEP 100
                 edmSetText hEdm32, FileUnWrapped
                 edmTxtFindNext hEdm32, LTRIM$(TextLine), 0, 0, 0, 1 'Find text
                 LineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0) + 1
                 CALL SendMessage(hEdm32, %EDM_SETBMCOLOR, RGB(64, 128, 128), 1) 'Green dark
                 edmBookMarkSet hEdm32, LineNum - 1, 1  'Set bookmark
                 CALL SendMessage(hEdm32, %EDM_GOTOLINE, LineNum, 1)
                 CALL edmGetSubs(hEdm32, hCbFunc, 0) 'populate sub/function finder combo
               ELSE
               END IF
             ELSE 'Switch from View-File to View-Result
               ViewFile = 0
               FindPosFirst = -1
               IF Quick = 0 THEN
                 MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
                 Retval = Retval AND %MF_CHECKED
                 MENU SET STATE hMenu, BYCMD %PopBlank, Retval
               END IF
               DIALOG SET TEXT hDlg, DialogCaption
               CONTROL SET TEXT hDlg, %StatusBar, _
                                " Double-click to see file or right-click for options."
               CONTROL SET TEXT CBHNDL, %ButtonView, "Vi&ew"
               CONTROL ENABLE hDlg, %ButtonSearch
               ControlEnable 1
               CONTROL DISABLE hDlg, %ComboFunc
               CALL SendMessage(hEdm32, %EDM_SETCOLORPAGE, RGB(250, 250, 255), 0)
               CALL SendMessage(hEdm32, %EDM_SETCOLORTXTBK, RGB(250, 250, 255), 0)
               IF Quick THEN
                 edmSetText hEdm32, FileNameSet
                 MENU GET STATE hMenu, BYCMD %PopWrap TO Retval
                 Retval = Retval AND %MF_CHECKED
                 MENU SET STATE hMenu, BYCMD %PopWrap, %MF_GRAYED OR Retval
               ELSE
                 edmSetText hEdm32, sOut
               END IF
               CALL SendMessage(hEdm32, %EDM_SETBMCOLOR, RGB(255, 255, 0), 1)
               edmBookMarkSet hEdm32, LineNumSearch - 1, 1  'Set bookmark
               CALL SendMessage(hEdm32, %EDM_GOTOLINE, LineNumSearch, 1)
               SendMessage hEdm32, %EDM_SETTOPLINE, LineTopSearch, 1
             END IF
           END IF
       
         CASE %WM_COMMAND
           SELECT CASE CBCTL
       
             CASE %ButtonQuick '%CheckboxQuick
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 SendMessage hEdm32, %EDM_SETBMCOLOR, RGB(255, 255, 0), 1 'Yellow
                 IF Quick = 1 THEN
                   Quick = 0
                   MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
                   Retval = Retval AND %MF_CHECKED
                   MENU SET STATE hMenu, BYCMD %PopBlank, Retval
                   MENU GET STATE hMenu, BYCMD %PopWrap TO Retval
                   Retval = Retval AND %MF_CHECKED
                   MENU SET STATE hMenu, BYCMD %PopWrap, Retval
                   CONTROL SET TEXT hDlg, %ButtonQuick, "&Quick"
                   QuickTopLine = SendMessage(hEdm32, %EDM_GETTOPLINE, 0, 0)
                   QuickLineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0)
                   IF QuickLineNum <> FullLineNum THEN
                     QuickTextLine = FileNameGet
                     edmSetText hEdm32, sOut
                     edmBookMarkSet hEdm32, FullLineNum, 1  'Set bookmark
                     Retval = edmTxtFindNext(hEdm32, LTRIM$(QuickTextLine), 0, 0, 0, 1) 'Find text
                     Retval = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0)
                     SendMessage hEdm32, %EDM_SETCARETX, 0, 0
                     SendMessage hEdm32, %EM_SETSEL, 0, 0
                     SendMessage hEdm32, %EDM_SETTOPLINE, Retval, 1
                   ELSE
                     edmSetText hEdm32, sOut
                     edmBookMarkSet hEdm32, FullLineNum, 1  'Set bookmark
                     SendMessage hEdm32, %EDM_GOTOLINE,   FullLineNum + 1, 0
                     SendMessage hEdm32, %EDM_SETTOPLINE, FullTopLine, 1
                   END IF
                 ELSE
                   Quick = 1
                   MENU GET STATE hMenu, BYCMD %PopBlank TO Retval
                   Retval = Retval AND %MF_CHECKED
                   MENU SET STATE hMenu, BYCMD %PopBlank, %MF_GRAYED OR Retval
                   MENU GET STATE hMenu, BYCMD %PopWrap TO Retval
                   Retval = Retval AND %MF_CHECKED
                   MENU SET STATE hMenu, BYCMD %PopWrap, %MF_GRAYED OR Retval
                   CONTROL SET TEXT hDlg, %ButtonQuick, "&Quest"
                   FullTopLine = SendMessage(hEdm32, %EDM_GETTOPLINE, 0, 0)
                   FullLineNum = SendMessage(hEdm32, %EDM_GETCARETY, 0, 0)
                   Buffer = FileNameSet
                   IF LEN(Buffer) = 0 THEN Buffer = sOut '"Sorry, nothing found in 97 files."
                   edmSetText hEdm32, Buffer 'FileNameSet
                   edmBookMarkSet hEdm32, QuickLineNum, 1  'Set bookmark
                   SendMessage hEdm32, %EDM_GOTOLINE,   QuickLineNum + 1, 0
                   SendMessage hEdm32, %EDM_SETTOPLINE, QuickTopLine, 1
                 END IF
               END IF
       
             CASE %IDOK
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 IF ViewFile = 0 THEN
                   CONTROL SEND CBHNDL, %ButtonSearch, %BM_CLICK, 0, 0
                 ELSE
                   'Go from view window to result window.
                   NmhdrMsg.hWndFrom = hEdm32
                   NmhdrMsg.code = %NM_FIRST - 3
                   DIALOG SEND hDlg, %WM_NOTIFY, %EDM32, VARPTR(NmhdrMsg)
                 END IF
               END IF
       
             CASE %ComboFunc
               SELECT CASE HIWRD(CBWPARAM)
                  CASE %CBN_DROPDOWN             'Refresh list
                     edmGetSubs hEdm32, hCbFunc, 0
                  CASE %CBN_SELENDOK             'go to selected function/sub
                     SetFocus hEdm32             'close combo before going..
                     Retval = SendMessage(hCbFunc, %CB_GETCURSEL, 0, 0)
                     Retval = SendMessage(hCbFunc, %CB_GETITEMDATA, Retval, 0)
                     CALL SendMessage(hEdm32, %EDM_GOTOLINE, Retval, 1)
               END SELECT
       
             CASE %RadioExact
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 RadioSetLabel %RadioExact
               END IF
       
             CASE %RadioAnd
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 RadioSetLabel %RadioAnd
               END IF
       
             CASE %RadioOr
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 RadioSetLabel %RadioOr
               END IF
       
             CASE %ButtonView
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 'Result/View window.
                 NmhdrMsg.hWndFrom = hEdm32
                 NmhdrMsg.code = %NM_FIRST - 3
                 DIALOG SEND hDlg, %WM_NOTIFY, %EDM32, VARPTR(NmhdrMsg)
               END IF
       
             CASE %ButtonFolder
                 IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                   CONTROL GET TEXT CBHNDL, %ComboFolder TO sTmp
                   IF LEN(sTmp) < 1 THEN sTmp = CURDIR$
                   Folder = BrowseFolder(hDlg, "Choose a path to search...", sTmp)
                   IF LEN(Folder) THEN
                     CONTROL SEND CBHNDL, %ComboFolder, %CB_INSERTSTRING, 0, STRPTR(Folder)
                     cbCount = SendMessage(hCbFolder, %CB_GETCOUNT, 0, 0)
                     IF cbCount THEN
                       FOR Counter = 1 TO cbCount - 1
                         Buffer = SPACE$(SendMessage(hCbFolder, %CB_GETLBTEXTLEN, Counter, 0) + 1)
                         CALL SendMessage(hCbFolder, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
                         Buffer = LEFT$(Buffer, LEN(Buffer) - 1)
                         IF UCASE$(Buffer) = UCASE$(Folder) THEN
                           CALL SendMessage(hCbFolder, %CB_DELETESTRING, Counter, 0)
                           EXIT FOR
                         END IF
                       NEXT
                       COMBOBOX DELETE hDlg, %ComboFolder, 51 'Keep only last request
                     END IF
                     CONTROL SET TEXT CBHNDL, %ComboFolder, Folder
                     FolderPath = Folder
                   END IF
                   CONTROL SEND CBHNDL, %ComboFolder, %CB_SETCURSEL, 0, 0
                 END IF
       
             CASE %ButtonSearch
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
       
                 'Taking care of path listbox
                 CONTROL GET TEXT CBHNDL, %ComboFolder TO Folder
                 IF LEN(Folder) < 1 THEN Folder = CURDIR$
                 IF LEN(Folder) THEN
                   CONTROL SEND CBHNDL, %ComboFolder, %CB_INSERTSTRING, 0, STRPTR(Folder)
                   cbCount = SendMessage(hCbFolder, %CB_GETCOUNT, 0, 0)
                   IF cbCount THEN
                     FOR Counter = 1 TO cbCount - 1
                       Buffer = SPACE$(SendMessage(hCbFolder, %CB_GETLBTEXTLEN, Counter, 0) + 1)
                       CALL SendMessage(hCbFolder, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
                       Buffer = LEFT$(Buffer, LEN(Buffer) - 1)
                       IF UCASE$(Buffer) = UCASE$(Folder) THEN
                         CALL SendMessage(hCbFolder, %CB_DELETESTRING, Counter, 0)
                         EXIT FOR
                       END IF
                     NEXT
                     COMBOBOX DELETE hDlg, %ComboFolder, 51 'Keep only last request
                   END IF
                   CONTROL SET TEXT CBHNDL, %ComboFolder, Folder
                   FolderPath = Folder
                 END IF
       
                 'Taking care of search listbox
                 CONTROL GET TEXT hDlg, %ButtonSearch TO Buffer
                 IF Buffer = $Stop THEN
                   SearchCancel = 1
                 ELSE
                   IF LEN(FolderPath) < 1 THEN BEEP : ShakeDialog hDlg : EXIT FUNCTION
                   FileUnWrapped = "" 'Release memory
                   CALL SendMessage(hEdm32, %EDM_DELETE, 1, 0)'Release memory
                   CONTROL GET TEXT CBHNDL, %ComboSearch TO sTmp
                   sTmp = REMOVE$(sTmp, ANY $NUL)
                   IF LEN(LTRIM$(sTmp)) < 1 THEN BEEP : ShakeDialog hDlg : EXIT FUNCTION
                   sTmp = SpaceShrink(sTmp)
                   CONTROL SEND CBHNDL, %ComboSearch, %CB_INSERTSTRING, 0, STRPTR(sTmp)
                   cbCount = SendMessage(hCbSearch, %CB_GETCOUNT, 0, 0)
                   IF cbCount THEN
                     FOR Counter = 1 TO cbCount - 1
                       Buffer = SPACE$(SendMessage(hCbSearch, %CB_GETLBTEXTLEN, Counter, 0) + 1)
                       CALL SendMessage(hCbSearch, %CB_GETLBTEXT, Counter, STRPTR(Buffer))
                       Buffer = LEFT$(Buffer, LEN(Buffer) - 1)
                       IF UCASE$(Buffer) = UCASE$(sTmp) THEN
                         CALL SendMessage(hCbSearch, %CB_DELETESTRING, Counter, 0)
                         EXIT FOR
                       END IF
                     NEXT
                     COMBOBOX DELETE hDlg, %ComboSearch, 51 'Keep only last request
                   END IF
                   CONTROL SET TEXT CBHNDL, %ComboSearch, sTmp
       
                   'Taking care of chexkbox
                   IF CheckBoxGet = 0 OR CheckBoxGet = 1024 THEN CheckBoxSet 1 + 2 + 4 + 8 + 16 + 32
                   sTmp = LCASE$(sTmp)
                   FindAction = RadioGet 'Return %FindExact or %FindAnd or %FindOr
                   SELECT CASE FindAction
                     CASE %FindOr, %FindAnd
                       sTmp = TRIM$(SpaceShrink(sTmp))
                       REDIM sTmpArray(1 TO PARSECOUNT(sTmp, $SPC))
                       PARSE sTmp, sTmpArray(), $SPC
                     CASE ELSE '%FindExact
                       REDIM sTmpArray(1 TO 1)
                       Retval = CheckBoxGet
                       If ISFALSE(Retval AND %CheckAny) AND ISFALSE(Retval AND %CheckFile) THEN
                         sTmpArray(1) = TRIM$(SpaceShrink(sTmp))
                       ELSE
                         sTmpArray(1) = SpaceShrink(sTmp) 'One leading space will remain if any
                       END IF
                   END SELECT
                   SearchFiles CBHNDL, sTmpArray(), FindAction
                   IF Quick = 1 THEN
                     Quick = 0
                     CONTROL SEND hDlg, %ButtonQuick, %BM_CLICK, 0, 0
                   END IF
       
                 END IF
               END IF
       
             CASE %ButtonSet
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CONTROL GET TEXT hDlg, %ButtonSet TO Buffer
                 IF Buffer = "Se&t" THEN
                   CONTROL SET TEXT hDlg,  %ButtonSet, "Rese&t"
                   CONTROL SET CHECK hDlg, %CheckAny, 0
                   CONTROL SET CHECK hDlg, %CheckFile, 0
                   Retval = 1
                 ELSE
                   CONTROL SET TEXT hDlg,  %ButtonSet, "Se&t"
                   CONTROL SET CHECK hDlg, %CheckElse, 0
                   Retval = 0
                 END IF
                 FOR Counter = %CheckConst TO %CheckSub '%CheckElse
                   CONTROL SET CHECK hDlg, Counter, Retval
                 NEXT
               END IF
       
             CASE %CheckConst TO %CheckElse
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CONTROL SET CHECK hDlg, %CheckAny, 0
                 CONTROL SET CHECK hDlg, %CheckFile, 0
               END IF
       
             CASE %CheckInside
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CONTROL SET CHECK hDlg, %CheckAny, 0
               END IF
       
             CASE %LabelInside
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CONTROL SEND hDlg, %CheckInside, %BM_CLICK, 0, 0
               END IF
       
             CASE %CheckFile                                               '   1 %CheckConst        = 2001
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN              '   2 %CheckUnion        = 2002
                 CONTROL GET CHECK hDlg, %CheckFile TO Retval              '   4 %CheckType         = 2003
                 IF Retval THEN                                            '   8 %CheckMacro        = 2004
                   IF ISFALSE(CheckBoxGet AND 512) THEN 'CheckAny is off   '  16 %CheckFunc         = 2005
                     CONTROL SET TEXT hDlg,  %ButtonSet, "Se&t"            '  32 %CheckSub          = 2006
                     CheckItBak = CheckBoxGet - 2048 'File                 ' 128 %CheckElse         = 2007
                     FOR Counter = %CheckConst TO %CheckElse               ' 512 %CheckAny          = 2011
                       CONTROL SET CHECK hDlg, Counter, 0                  '1024 %CheckInside       = 2021
                     NEXT                                                  '2048 CheckFile          = 2023
                     CONTROL SET CHECK hDlg, %CheckInside, 0
                   ELSE
                     CONTROL SET CHECK hDlg, %CheckAny, 0
                   END IF
                 ELSE
                   CheckBoxSet CheckItBak
                   CheckItBak = 0
                 END IF
               END IF
       
             CASE %CheckAny
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CONTROL GET CHECK hDlg, %CheckAny TO Retval
                 IF Retval THEN
                   IF ISFALSE(CheckBoxGet AND 2048) THEN 'CheckFile is off
                     CONTROL SET TEXT hDlg,  %ButtonSet, "Se&t"
                     CheckItBak = CheckBoxGet - 512
                     FOR Counter = %CheckConst TO %CheckElse
                       CONTROL SET CHECK hDlg, Counter, 0
                     NEXT
                     CONTROL SET CHECK hDlg, %CheckInside, 0
                   ELSE
                     CONTROL SET CHECK hDlg, %CheckFile, 0
                   END IF
                 ELSE
                   CheckBoxSet CheckItBak
                   CheckItBak = 0
                 END IF
               END IF
       
             CASE %ButtonPreset1 TO %ButtonPreset4
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 IF ViewFile = 0 THEN
                   Retval = CBCTL -  %ButtonPreset1 + 1
                   IF ISTRUE(LOWRD(GetKeyState(%VK_CONTROL)) AND &H8000) THEN 'Ctrl-Click or Ctrl-1
                      CONTROL GET TEXT CBHNDL, %ComboFolder TO PresetFolder(Retval)
                      PresetCheckBox(Retval) = CheckBoxGet
                      PresetCheckBoxFilter(Retval) = CheckBoxFilterGet
                      CONTROL GET CHECK hDlg, %CheckSubDir TO PresetCheckBoxSubDir(Retval)
                   ELSE 'Click or Alt-1
                      PresetLast = CBCTL ': MsgBox Str$(PresetLast)
                      FOR Counter = %ButtonPreset1 TO %ButtonPreset4
                        IF Counter = CBCTL THEN
                          FontMakeBold(Counter, 2)
                        ELSE
                          FontMakeBold(Counter, 1)
                        END IF
                      NEXT
                      IF LEN(PresetFolder(Retval)) THEN CONTROL SET TEXT CBHNDL, %ComboFolder, PresetFolder(Retval)
                      CheckBoxSet PresetCheckBox(Retval)
                      CheckBoxFilterSet PresetCheckBoxFilter(Retval)
                      CONTROL SET CHECK hDlg, %CheckSubDir, PresetCheckBoxSubDir(Retval)
                   END IF
                 END IF
               END IF
       
             CASE %ButtonFindNext, %ButtonFindPrev
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 Buffer = edmTxtGetSelText(hEdm32, 1) 'Get Edm32 selected text
                 IF LEN(Buffer) THEN
                   CONTROL SET TEXT CBHNDL, %ComboFind, Buffer
                 ELSE 'Get Buffer from combo
                   CONTROL GET TEXT CBHNDL, %ComboFind TO Buffer
                 END IF
       
                 'Taking care of find-combo
                 IF LEN(LTRIM$(Buffer)) < 1 THEN BEEP : ShakeDialog hDlg : EXIT FUNCTION
                 CONTROL SEND CBHNDL, %ComboFind, %CB_INSERTSTRING, 0, STRPTR(Buffer)
                 cbCount = SendMessage(hCbFind, %CB_GETCOUNT, 0, 0)
                 IF cbCount THEN
                   FOR Counter = 1 TO cbCount - 1
                     sTmp = SPACE$(SendMessage(hCbFind, %CB_GETLBTEXTLEN, Counter, 0) + 1)
                     CALL SendMessage(hCbFind, %CB_GETLBTEXT, Counter, STRPTR(sTmp))
                     sTmp = LEFT$(sTmp, LEN(sTmp) - 1)
                     IF UCASE$(sTmp) = UCASE$(Buffer) THEN
                       CALL SendMessage(hCbFind, %CB_DELETESTRING, Counter, 0)
                       EXIT FOR
                     END IF
                   NEXT
                   COMBOBOX DELETE hDlg, %ComboFind, 51 'Keep only last request
                   CONTROL SET TEXT CBHNDL, %ComboFind, Buffer
                 END IF
       
                 IF LEN(Buffer) THEN
                   IF edmTxtReplaceAll(hEdm32, Buffer, "", 0, 0, 1) > 0 THEN 'Count of Buffer occurences
                     IF LCASE$(sFindOld) <> LCASE$(Buffer) THEN FindPosFirst = -1
                     sFindOld = Buffer
                     IF CBCTL = %ButtonFindPrev THEN NextPrev = 1 ELSE NextPrev = 0
                     Retval = edmTxtFindNext(hEdm32, Buffer, NextPrev, 0, 0, 1) 'Find text
                     IF Retval = 0 THEN 'Not found
                       IF NextPrev = 0 THEN 'Find next
                         CALL SendMessage(hEdm32, %EDM_GOTOLINE, 1, 1) 'Restart search at line 1
                       ELSE 'Find previous
                         Retval = SendMessage(hEdm32, %EDM_GETLINECOUNT, 0, 0)
                         CALL SendMessage(hEdm32, %EDM_GOTOLINE, Retval, 1) 'Restart search at the end
                         CALL SendMessage(hEdm32, %EDM_SETCARETX, -1, 0)
                       END IF
                       Retval = edmTxtFindNext(hEdm32, Buffer, NextPrev, 0, 0, 1) 'Find text
                     END IF
                     IF NextPrev = 0 THEN
                       CONTROL SET FOCUS hDlg, %ButtonFindNext
                     ELSE
                       CONTROL SET FOCUS hDlg, %ButtonFindPrev
                     END IF
                     IF FindPosFirst = Retval THEN
                       BEEP 'We are back to the starting point
                     END IF
                     IF FindPosFirst = -1 THEN FindPosFirst = Retval
                   ELSE
                     BEEP 'Buffer not found
                   END IF
                 END IF
                 Buffer = FileNameGet
                 CONTROL SET TEXT hDlg, %StatusBar, " Double-click to see " & Buffer & " or right-click for options."
               END IF
       
             CASE %ComboFind
               IF HIWRD(CBWPARAM) = %CBN_EDITUPDATE OR HIWRD(CBWPARAM) = %CBN_SELENDOK THEN
                 CALL SendMessage(hEdm32, %EM_SETSEL, -1 , 0)
               END IF
       
             CASE %ButtonHint
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 MessageBox hDlg, $AppName & $SPC & $AppVer                              & $CRLF & $CRLF & _
                        "Hint..."                                                        & $CRLF & $CRLF & _
                        "Highlight some text and click Jump or Prev"                     & $CRLF & $CRLF & _
                        "Combobox-Path may have many paths separated by semicolon "";""" & $CRLF & $CRLF & _
                        "Double click on a result line to see the file it came from."    & $CRLF & $CRLF & _
                        " If Poffs is set in Editor/Help, it will be started with"       & $CRLF & _
                        "either Combo-Search text or highlighted text,"                  & $CRLF & _
                        "the same apply to .hlp files"                                   & $CRLF & $CRLF & _
                        " Buttons 1 to 4 memorise Path-Combo and checkboxs,"             & $CRLF & _
                        "use Ctrl-Click or Ctrl-(1 to 4) to set them."                   & $CRLF & $CRLF & _
                        "________________________________________"                       & $CRLF & $CRLF & _
                        "GotCha, a search engine for PowerBasic code."                   & $CRLF & $CRLF & _
                        "Coded by Pierre Bellisle"                                       & $CRLF & $CRLF & _
                        "Based on Wayne Diamond's PBDecs"                                & $CRLF & $CRLF & _
                        "EDM32 richedit control by fabulous B" & CHR$(246) & "rje Hagsten" & $NUL _
                        , $AppName & " - Hint" & $NUL, %MB_ICONINFORMATION OR %MB_OK
               END IF
       
             CASE %ButtonOption
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 GetCursorPos pt
                 TrackPopupMenu hmenu, %TPM_LEFTALIGN OR %TPM_RIGHTBUTTON, pt.x, pt.y, BYVAL 0, CBHNDL, BYVAL 0
               END IF
       
             CASE %ButtonExit, %IDCancel
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 DIALOG END CBHNDL, 0
               END IF
       
             CASE %PopWrap
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CALL SendMessage(hEdm32, %EDM_GETWORDWRAP, 0, 0) TO Retval
                 IF Retval THEN
                   MENU SET STATE hMenu, BYCMD %PopWrap, %MF_UNCHECKED
                   CALL SendMessage(hEdm32, %EDM_SETWORDWRAP, 0, 0)
                 ELSE
                   MENU SET STATE hMenu, BYCMD %PopWrap, %MF_CHECKED
                   CALL SendMessage(hEdm32, %EDM_SETWORDWRAP, 1, 0)
                 END IF
                 IF ViewFile = 1 THEN
                   edmSetText hEdm32, FileUnWrapped
                 ELSE
                   edmSetText hEdm32, sOut
                 END IF
               END IF
       
             CASE %PopSyntax
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CALL SendMessage(hEdm32, %EDM_GETSYNTAXONOFF, 0, 0) TO Retval
                 IF Retval THEN
                   MENU SET STATE hMenu, BYCMD %PopSyntax, %MF_UNCHECKED
                   CALL SendMessage(hEdm32, %EDM_SETSYNTAXONOFF, 0, 0)
                 ELSE
                   MENU SET STATE hMenu, BYCMD %PopSyntax, %MF_CHECKED
                  CALL SendMessage(hEdm32, %EDM_SETSYNTAXONOFF, 1, 0)
                 END IF
               END IF
       
             CASE %PopGrid
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CALL SendMessage(hEdm32, %EDM_GETGRID, 0, 0) TO Retval
                 IF Retval THEN
                   MENU SET STATE hMenu, BYCMD %PopGrid, %MF_UNCHECKED
                   SendMessage hEdm32, %EDM_SETGRID, 0, 0
                 ELSE
                   MENU SET STATE hMenu, BYCMD %PopGrid, %MF_CHECKED
                   SendMessage hEdm32, %EDM_SETGRID, 1, 0
                 END IF
               END IF
       
             CASE %PopBlank
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 MENU GET STATE hMenu, BYCMD %PopBlank TO  Retval
                 IF Retval THEN
                   MENU SET STATE hMenu, BYCMD %PopBlank, %MF_UNCHECKED
                   REPLACE $CRLF & $CRLF WITH $CRLF IN sOut
                   edmSetText hEdm32, sOut
                 ELSE
                   MENU SET STATE hMenu, BYCMD %PopBlank, %MF_CHECKED
                   Retval = PARSECOUNT(sOut, $CRLF)
                   REDIM sOutArray(1 TO Retval) AS STRING
                   PARSE sOut, sOutArray(), $CRLF
                   sOut = ""
                   FOR Counter = 1 TO Retval - 1
                     IF LEFT$(sOutArray(Counter), 1) = " " OR _
                        LEFT$(sOutArray(Counter + 1), 1) = " "  OR _
                        LEFT$(sOutArray(Counter + 1), 5) = "'>>> " THEN
                       sOut = sOut & sOutArray(Counter) & $CRLF
                     ELSE
                       sOut = sOut & sOutArray(Counter) & $CRLF & $CRLF
                     END IF
                   NEXT
                   RESET  sOutArray()
                   edmSetText hEdm32, sOut
                 END IF
               END IF
       
             CASE %PopCopy
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 Retval = Sendmessage(hEDM32, %EDM_GETSELLENGTH, 0, 0)  'Selection length
                 IF Retval = 0 THEN
                   CALL SendMessage(hEdm32, %EM_SETSEL, 0, -1)
                 END IF
                 CALL SendMessage(hEdm32, %EDM_COPY, 0, 0)
               END IF
       
             CASE %PopPaste
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 CALL SendMessage(hEdm32, %EDM_PASTE, 0, 0)
               END IF
       
             CASE %PopRunExe
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 FileName = FileNameGet
                 FileName = LEFT$(FileName, INSTR(-1, FileName, ".")) & "exe"
                 IF FileExist(FileName) THEN
                   Retval = SHELL(FileName, 4)
                 ELSE
                   Beep
                   ShakeDialog hDlg
                 END IF
               END IF
       
             CASE %PopExplore, %PopWinSearch, %PopCommand
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 IF ViewFile = 1 THEN
                   DIALOG GET TEXT hDlg TO FileName
                   FileName = LEFT$(FileName, INSTR(-1, FileName, "\"))
                   zFolder = MID$(FileName, 10) 'GotCha - C:\...
                 ELSE
                   Buffer = FileNameGet
                   zFolder = LEFT$(Buffer, INSTR(-1, Buffer, "\"))
                   IF LEN(zFolder) < 1 THEN
                     CONTROL GET TEXT CBHNDL, %ComboFolder TO zFolder
                   END IF
                 END IF
                 IF CBCTL = %PopExplore THEN
                   Retval = ShellExecute(%NULL, "EXPLORE", zFolder, "", "", %SW_SHOWNORMAL)
                 ELSEIF CBCTL = %PopWinSearch THEN
                   Retval = ShellExecute(%NULL, "FIND", zFolder, "", "", %SW_SHOWNORMAL)
                 ELSE
                   IF IsNt THEN
                     ShellExecute 0, "open", "cmd.exe", "/k", zFolder, 1 To Retval
                   ELSE
                     ShellExecute 0, "open", "command.com", "/k", zFolder, 1 To Retval
                   END IF
                 END IF
               END IF
       
             CASE %PopClipFN
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 IF ViewFile = 1 THEN
                   DIALOG GET TEXT hDlg TO Buffer
                   Buffer = MID$(Buffer, INSTR(Buffer, "- ") + 2)
                 ELSE
                   Buffer = FileNameGet
                 END IF
                 IF LEN(Buffer) = 0 THEN
                   CONTROL GET TEXT hDlg, %ComboFolder TO Buffer
                 END IF
                 IF LEN(Buffer) THEN
                   edmClipboardPutText Buffer
                 END IF
               END IF
       
             CASE %PopEditorAdd
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 EditorGet
               END IF
       
             CASE %PopEditorSep + 1 TO %PopEditorSep + UBOUND(Editor())
               IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                 IF RIGHT$(UCASE$(PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2)), 4) = ".CHM" THEN
                   'Call HH.Exe with .chm file
                   Retval = Shell("HH.EXE " & PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2))
                 ELSEIF RIGHT$(UCASE$(PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2)), 4) = ".COL" THEN
                   Buffer = edmTxtGetSelText(hEdm32, 1) 'Get Edm32 selected text
                   IF LEN(Buffer) = 0 THEN CONTROL GET TEXT hDlg, %ComboSearch TO Buffer
                   HelpCol PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2), Buffer
                 ELSEIF RIGHT$(UCASE$(PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2)), 4) = ".HLP" THEN
                   'Call WinHelp
                   zString = PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2)
                   Buffer = edmTxtGetSelText(hEdm32, 1) 'Get Edm32 selected text
                   IF LEN(Buffer) = 0 THEN
                     IF INSTR(UCASE$(zString), "PBCC")  OR _
                        INSTR(UCASE$(zString), "PBDLL") OR _
                        INSTR(UCASE$(zString), "PBWIN") THEN
                        Buffer = "%DEF"
                     ELSE
                       CONTROL GET TEXT hDlg, %ComboSearch TO Buffer
                     END IF
                   END IF
                   Retval = WinHelp (CBHNDL, zString, %HELP_PARTIALKEY, STRPTR(Buffer))
                 ELSEIF INSTR(UCASE$(PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2)), "POFFS") THEN
                   'Call POFFS and set POFFS-search-combo with GotCha-search-combo or selected text
                   hHandle = GetForegroundWindow()
                   Do
                     hHandle = GetNextWindow(hHandle, %GW_HWNDNEXT)
                     Retval = GetWindowText(hHandle, zString, BYCOPY %Max_Path)
                     Buffer = LEFT$(zString, Retval - 0)  'Remove null character  (-1 v2.24) (-0 v2.25 2003-10-03)
                     If InStr(UCASE$(zString), "POFFS V") Then
                       If LEN(Buffer) = 11 THEN
                         IF IsIconic(hHandle) THEN ShowWindow hHandle, %SW_RESTORE '2003-10-03  ELSE ShowWindow hwnd, %SW_SHOW
                         Exit Do 'POFFS v2.20
                       END IF
                     END IF
                   Loop UNTIL hHandle = 0
                   IF hHandle = 0 THEN
                     Retval = SHELL($DQ & PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2) & $DQ)
                     SLEEP 350
                     hHandle = GetForeGroundWindow
                   END IF
                   SetForeGroundWindow hHandle
                   Buffer = edmTxtGetSelText(hEdm32, 1) 'Get Edm32 selected text
                   IF LEN(Buffer) = 0 OR INSTR(Buffer, $CR) THEN 'No selected text or selection too big(MultiLine)
                     CONTROL GET TEXT hDlg, %ComboSearch TO Buffer
                   END IF
                   GetWindowText hHandle, BYVAL VARPTR(zString), %Max_Path
                   IF INSTR(UCASE$(zString), "POFFS") THEN
                     hHandle = GetDlgItem(hHandle, 1056)
                     SendMessage hHandle, %WM_SETTEXT, 0 ,STRPTR(Buffer)
                   END IF
                 ELSE
                   'Call editor
                   Buffer = FileNameGet
                   IF ISTRUE(LEN(DIR$(Buffer))) AND ISFALSE(GETATTR(Buffer) AND %SUBDIR) THEN
                       Retval = SHELL($DQ & PARSE$(Editor(CBCTL - %PopEditorSep), $TAB, 2) _
                                & $DQ & $SPC & Buffer)
                   ELSE
                     BEEP
                     ShakeDialog hDlg
                   END IF
                 END IF
               END IF
           END SELECT
       
         CASE %WM_HSCROLL
           IF GetDlgCtrlID(CBLPARAM) = %UpDownFind THEN
             IF LOWRD(CBWPARAM) = %SB_THUMBPOSITION THEN '4
               IF LOWRD(SendMessage(GetDlgItem(hDlg, %UpDownFind), 
      M_GETPOS,0,0)) <> 0 THEN 'Right
                 CONTROL GET TEXT hDlg, %ComboSearch TO Buffer
                 IF LEN(Buffer) THEN
                   CALL SendMessage(hEdm32, %EDM_RESETSEL, -1 , 0)
                   CONTROL GET TEXT hDlg, %ComboFind TO sTmp
                   IF Buffer <> sTmp THEN
                     FindPrev = sTmp
                     CONTROL SET TEXT hDlg, %ComboFind, Buffer
                   ELSE
                     CONTROL SET TEXT hDlg, %ComboFind, FindPrev
                   END IF
                 END IF
               ELSE 'Left
                 CONTROL GET TEXT hDlg, %ComboFind TO Buffer
                 IF LEN(Buffer) THEN
                   CALL SendMessage(hEdm32, %EDM_RESETSEL, -1 , 0)
                   CONTROL GET TEXT hDlg, %ComboSearch TO sTmp
                   IF Buffer <> sTmp THEN
                     SearchPrev = sTmp
                     CONTROL SET TEXT hDlg, %ComboSearch, Buffer
                   ELSE
                     CONTROL SET TEXT hDlg, %ComboSearch, SearchPrev
                   END IF
                 END IF
               END IF
             END IF
           END IF
       
         CASE %WM_VSCROLL
           IF GetDlgCtrlID(CBLPARAM) = %UpdownFN THEN 'Updown control
             IF LOWRD(CBWPARAM) = %SB_THUMBPOSITION THEN '4
               IF LOWRD(SendMessage(GetDlgItem(hDlg, %UpdownFN), 
      M_GETPOS,0,0)) <> 0 THEN 'UP
                 CALL SendMessage(hEdm32, %EDM_GETCARETY, 0, 0) TO EdmLineCurrent
                 CALL SendMessage(hEdm32, %EDM_GETLINECOUNT, 0, 0) TO EdmLineCount
                 Retval = 0
                 FOR Counter = EdmLineCurrent -1 TO 0 STEP - 1 'Search for previous Path string
                   Buffer = edmTxtGetLine(hEdm32, Counter)
                   IF LEFT$(Buffer, 5) = "'>>> " THEN
                     SendMessage hEdm32, %EDM_GOTOLINE, Counter + 1, 0
                     SendMessage hEdm32, %EDM_SETTOPLINE, Counter, 1
                     Retval = 1
                     EXIT FOR
                   END IF
                 NEXT
                 IF Retval = 0 THEN 'No previous Path string, so restart at the end
                   FOR Counter = EdmLineCount TO EdmLineCurrent STEP - 1
                     Buffer = edmTxtGetLine(hEdm32, Counter)
                     IF LEFT$(Buffer, 5) = "'>>> " THEN
                       SendMessage hEdm32, %EDM_GOTOLINE, Counter + 1, 0
                       SendMessage hEdm32, %EDM_SETTOPLINE, Counter, 1
                       EXIT FOR
                     END IF
                   NEXT
                   BEEP
                   ShakeDialog hDlg
                 END IF
               ELSE 'DOWN
                 CALL SendMessage(hEdm32, %EDM_GETCARETY, 0, 0) TO EdmLineCurrent
                 CALL SendMessage(hEdm32, %EDM_GETLINECOUNT, 0, 0) TO EdmLineCount
                 Retval = 0
                 FOR Counter = EdmLineCurrent + 1 TO EdmLineCount 'Search for next Path string
                   Buffer = edmTxtGetLine(hEdm32, Counter)
                   IF LEFT$(Buffer, 5) = "'>>> " THEN
                     SendMessage hEdm32, %EDM_GOTOLINE, Counter + 1, 0
                     SendMessage hEdm32, %EDM_SETTOPLINE, Counter, 1
                     Retval = 1
                     EXIT FOR
                   END IF
                 NEXT
                 IF Retval = 0 THEN 'No subsequent Path string, so restart at the beginning
                   SendMessage hEdm32, %EDM_GOTOLINE,  1, 0
                   SendMessage hEdm32, %EDM_SETTOPLINE, 0, 1
                   BEEP
                   ShakeDialog hDlg
                 END IF
               END IF
               Buffer = FileNameGet
               CONTROL SET TEXT hDlg, %StatusBar, " Double-click to see " & Buffer & " or right-click for options."
             END IF
           END IF
       
         CASE %WM_NCACTIVATE
           IF CBWPARAM THEN
             CALL SetFocus(hFocus)  '<- set focus as it was
           ELSE
             hFocus = GetFocus      '<- set focus as it was
           END IF
       
         CASE %WM_SIZE 'resize edit control if parent is resized
           SendMessage hStatusbar,CBMSG, CBWPARAM, CBLPARAM
           IF CBWPARAM <> %SIZE_MINIMIZED THEN ControlSetSize
           Retval = SendMessage(hEdm32, %EDM_GETWORDWRAP, 0, 0)
           IF Retval THEN
             IF ViewFile = 1 THEN
               edmSetText hEdm32, FileUnWrapped
             ELSE
               edmSetText hEdm32, sOut
             END IF
           END IF
       
         CASE %WM_GETMINMAXINFO
           MinMaxInfoPtr = CBLPARAM 'Dialog won't go under that size
           DIALOG UNITS hDlg, 195, 150 TO PIXELS _
                  @MinMaxInfoPtr.ptMinTrackSize.x, @MinMaxInfoPtr.ptMinTrackSize.y
       
         CASE %WM_CLOSE
           IniFileSave 'App. is about to end, so it's time to save our dialog coordinates.
       
         CASE %WM_SYSCOMMAND
           IF CBCTL = %SC_CLOSE THEN 'IF (CBWPARAM AND &HFFF0) = %SC_CLOSE THEN
             hMenuState = GetSystemMenu(hDlg, 0)
             IF ISTRUE(GetMenuState(hMenuState, %SC_CLOSE, %MF_BYCOMMAND OR %MF_GRAYED) AND %MF_GRAYED) THEN
               SearchCancel = 1
               FUNCTION = 1  'App won't terminate, even with ALT-F4
             END IF
           END IF
       
       END SELECT
       
      END FUNCTION
      '______________________________________________________________________________
       
      FUNCTION PBMAIN() AS LONG
       
       LOCAL ICC    AS INIT_COMMON_CONTROLSEX
       LOCAL Retval AS LONG
       
       DIALOG NEW 0, $AppName & " - Version " & $AppVer, 0, 0, 520, 275, %WS_POPUP OR %WS_BORDER OR %WS_MAXIMIZEBOX _
                  OR %WS_DLGFRAME OR %WS_THICKFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX _
                  OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_SETFOREGROUND _
                  OR %DS_CENTER OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT _
                  ,%WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
                  OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
       
       ICC.dwSize = SIZEOF(ICC)
       ICC.dwICC = %ICC_INTERNET_CLASSES
       CALL InitCommonControlsEx(ICC)
       
       SetClassLong hDlg, %GCL_HICON, LoadIcon(GetModuleHandle(ByVal 0&), BYVAL %RcIcon) 'Set caption icon
       
       CONTROL ADD COMBOBOX, hDlg, %ComboFunc,   , 5, 5, 140, 250 _
                           , %CBS_AUTOHSCROLL OR %CBS_DROPDOWN OR %WS_TABSTOP OR %WS_VSCROLL OR %CBS_SORT
       CONTROL SET COLOR hDlg, %ComboFunc, %BLUE, %WHITE
       CONTROL DISABLE hDlg, %ComboFunc
       
       CONTROL ADD COMBOBOX, hDlg, %ComboFolder, , 5, 24, 140, 250 _
                           , %CBS_AUTOHSCROLL OR %CBS_DROPDOWN OR %WS_TABSTOP OR %WS_VSCROLL
       CONTROL SET COLOR hDlg, %ComboFolder, %BLUE, %WHITE
       
       CONTROL ADD COMBOBOX, hDlg, %ComboSearch, , 5, 43, 140, 250 _
                           , %CBS_AUTOHSCROLL OR %CBS_DROPDOWN OR %WS_TABSTOP OR %WS_VSCROLL
       CONTROL SET COLOR hDlg, %ComboSearch, %BLUE, %WHITE
       
       CONTROL ADD OPTION, hDlg, %RadioExact, "Exact ",  3, 59, 35, 12 ,%BS_LEFT  OR %BS_VCENTER OR %WS_GROUP, %WS_EX_LEFT
       CONTROL SET COLOR   hDlg, %RadioExact, %YELLOW, -2&
       CONTROL ADD OPTION, hDlg, %RadioAnd  , "And "  , 39, 59, 30, 12 ,%BS_LEFT  OR %BS_VCENTER, %WS_EX_LEFT
       CONTROL SET COLOR   hDlg, %RadioAnd, %YELLOW, -2&
       CONTROL ADD OPTION, hDlg, %RadioOr   , "&Or "  , 68, 59, 25, 12 ,%BS_LEFT  OR %BS_VCENTER, %WS_EX_LEFT
       CONTROL SET COLOR   hDlg, %RadioOr, %YELLOW, -2&
       CONTROL SET OPTION  hDlg, %RadioExact, %RadioExact, %RadioOr
       
       CONTROL ADD LABEL,  hDlg, %LabelExactAndOr, "" , 10, 69, 110, 12
       CONTROL SET COLOR   hDlg, %LabelExactAndOr, %YELLOW, -2&
       
       CONTROL ADD CHECKBOX, hDlg, %CheckWhole , "&Whole ", 93, 59, 34, 12 ', 0, %WS_EX_TRANSPARENT
       CONTROL SET COLOR     hDlg, %CheckWhole, %YELLOW, -2&
       
       CONTROL ADD "msctls_updown32", hDlg, %UpDownFN, "msctls_updown321", 130, 61, 20, 15 _
                                    , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR 
      S_ARROWKEYS 'OR 
      S_HORZ
       CONTROL SEND hDlg, %UpDownFN, 
      M_SETRANGE, 0, MAKLNG(1,0) 'Range 0 to 1
       CONTROL SEND hDlg, %UpDownFN, 
      M_SETPOS, 0, 0
       CONTROL SET SIZE hDlg, %UpDownFN, 15, 15
       
       CONTROL ADD BUTTON  , hDlg, %ButtonView, "Vi&ew"  , 150, 5, 35, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       CONTROL ADD BUTTON  , hDlg, %ButtonFolder, "&Path", 150, 24, 35, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       CONTROL ADD BUTTON  , hDlg, %ButtonSearch, $Search, 150, 43, 35, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       CONTROL ADD BUTTON  , hDlg, %ButtonQuick, "&Quick", 150, 62, 35, 13 _ 'Quick view
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       CONTROL ADD BUTTON  , hDlg, %ButtonSet, "Se&t", 200, 4, 35, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       CONTROL ADD CHECKBOX, hDlg, %CheckConst , "&Const ", 200, 20, 33, 10 ', 0, %WS_EX_TRANSPARENT
       CONTROL SET COLOR     hDlg, %CheckConst, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckUnion , "&Union ", 200, 30, 33, 10
       CONTROL SET COLOR     hDlg, %CheckUnion, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckType  , "T&ype " , 200, 40, 33, 10
       CONTROL SET COLOR     hDlg, %CheckType, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckMacro , "&Macro ", 200, 50, 33, 10
       CONTROL SET COLOR     hDlg, %CheckMacro, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckInside, "Search &inside " , 200, 60, 60, 10
       CONTROL ADD LABEL   , hDlg, %LabelInside,"Union/Type/Macro ", 213, 69, 65, 10, %SS_LEFT OR %SS_NOTIFY, %WS_EX_LEFT
       CONTROL SET COLOR     hDlg, %CheckInside, %YELLOW, -2&
       CONTROL SET COLOR     hDlg, %LabelInside,%YELLOW, -2&
       
       CONTROL ADD CHECKBOX, hDlg, %CheckFile  , "Fil&e " , 240, 5, 43, 10
       CONTROL SET COLOR     hDlg, %CheckFile, %YELLOW, -2&
       
       CONTROL ADD CHECKBOX, hDlg, %CheckFunc  , "&Func " , 240, 20, 43, 10
       CONTROL SET COLOR     hDlg, %CheckFunc, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckSub  , "Su&b "  , 240, 30, 43, 10
       CONTROL SET COLOR     hDlg, %CheckSub, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckElse  , "E&lse " , 240, 40, 33, 10
       CONTROL SET COLOR     hDlg, %CheckElse, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckAny   , "&Any "  , 240, 50, 33, 10
       CONTROL SET COLOR     hDlg, %CheckAny, %YELLOW, -2&
       
       CONTROL ADD FRAME   , hDlg, %Frame, ""                   , 292,  0, 66, 43
       CONTROL ADD CHECKBOX, hDlg, %CheckInc   , "i&nc, h "        , 300,  8, 33, 10
       CONTROL SET COLOR     hDlg, %CheckInc, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckBas   , "bas, bi, &rc ", 300, 18, 50, 10
       CONTROL SET COLOR     hDlg, %CheckBas, %YELLOW, -2&
       CONTROL ADD CHECKBOX, hDlg, %CheckSubDir , "Sub&Dir "     , 300, 28, 35, 10
       CONTROL SET COLOR     hDlg, %CheckSubDir, %YELLOW, -2&
       
       CONTROL ADD FRAME   , hDlg, %Frame, ""   , 292, 44, 66, 32
       CONTROL ADD LABEL   , hDlg, %LabelPreset, "Preset", 314, 50, 40, 12
       CONTROL SET COLOR     hDlg, %LabelPreset, %YELLOW, -2&
       CONTROL ADD BUTTON  , hDlg, %ButtonPreset1, "&1", 296, 59, 15, 15
       CONTROL ADD BUTTON  , hDlg, %ButtonPreset2, "&2", 311, 59, 15, 15
       CONTROL ADD BUTTON  , hDlg, %ButtonPreset3, "&3", 326, 59, 15, 15
       CONTROL ADD BUTTON  , hDlg, %ButtonPreset4, "&4", 341, 59, 15, 15
       
       CONTROL ADD FRAME   , hDlg, %Frame, "", 365, 0, 150, 43
       CONTROL ADD BUTTON  , hDlg, %ButtonFindNext, "&Jump", 370, 8, 30, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       CONTROL ADD BUTTON  , hDlg, %ButtonFindPrev, "Pre&v", 410, 8, 30, 13 _
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       CONTROL ADD LABEL,  hDlg, %LabelFind, "Find in text", 446, 11, 40, 12
       CONTROL SET COLOR   hDlg, %LabelFind, %YELLOW, -2&
       
       CONTROL ADD "msctls_updown32", hDlg, %UpDownFind, "msctls_updown321", 492, 8, 20, 10 _
                                    , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR 
      S_ARROWKEYS OR 
      S_HORZ
       CONTROL SEND hDlg, %UpDownFind , 
      M_SETRANGE, 0, MAKLNG(1,0) 'Range 0 to 1
       CONTROL SEND hDlg, %UpDownFind , 
      M_SETPOS, 0, 0
       CONTROL SET SIZE hDlg, %UpDownFind , 20, 10
       
       CONTROL ADD COMBOBOX, hDlg, %ComboFind, , 370, 24, 140, 250 _
                           , %CBS_AUTOHSCROLL OR %CBS_DROPDOWN OR %WS_TABSTOP OR %WS_VSCROLL
       CONTROL SET COLOR hDlg, %ComboFind, %BLUE, %WHITE
       CONTROL HANDLE hDlg, %ComboFind TO hCbFind             'store combo's handle in global variable
       
       CONTROL ADD LABEL,  hDlg, %LabelLineCol, "Line " & "Col " & "Sel ", 372, 48, 150, 12
       CONTROL SET COLOR   hDlg, %LabelLineCol, %YELLOW, -2&
       CONTROL ADD BUTTON  , hDlg, %ButtonHint,  "&Hint",  370, 61, 30, 14  '370
       CONTROL ADD BUTTON  , hDlg, %ButtonOption, "&Gear", 425, 61, 30, 14  '425
       CONTROL ADD BUTTON  , hDlg, %ButtonExit,   "E&xit", 480, 61, 30, 14 _'480
                           , %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING
       
       MENU NEW POPUP TO hmenu
       MENU ADD STRING, hmenu, "Syntax &highlight", %PopSyntax    , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Grid lines"      , %PopGrid      , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Blank lines"     , %PopBlank     , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Word wrap"       , %PopWrap      , %MF_ENABLED
       MENU ADD STRING, hmenu, "-"                , -1            , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Copy"            , %PopCopy      , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Paste"           , %PopPaste     , %MF_ENABLED
       MENU ADD STRING, hmenu, "Clip &Filename"   , %PopClipFN    , %MF_ENABLED
       MENU ADD STRING, hmenu, "-"                , -1            , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Run exe"         , %PopRunExe    , %MF_ENABLED
       MENU ADD STRING, hmenu, "Comman&d"         , %PopCommand   , %MF_ENABLED
       MENU ADD STRING, hmenu, "&Explore"         , %PopExplore   , %MF_ENABLED
       MENU ADD STRING, hmenu, "Win &Search"      , %PopWinSearch , %MF_ENABLED
       MENU ADD STRING, hmenu, "-"                , -1            , %MF_ENABLED
       MENU ADD STRING, hmenu, "Edi&tor/Help"     , %PopEditorAdd, %MF_ENABLED
       MENU SET STATE hMenu, BYCMD %PopSyntax, %MF_CHECKED
       
       hEdm32 = CreateEdm32edit(hDlg, %EDM32, 0, 60 + 19 + 0, 460, 195, %WS_CHILD OR %WS_VISIBLE OR _
                                %WS_VSCROLL OR %WS_HSCROLL, %WS_EX_CLIENTEDGE, 1)
       SendMessage hEdm32, %EDM_SETKBSHORTCUTS, %TRUE, 0      'tell control to use internal keyboard shortcuts
       CONTROL HANDLE hDlg, %ComboFunc TO hCbFunc             'store combo's handle in global variable
       edmGetSubs hEdm32, hCbFunc, 0                          'initialize sub/function finder combo
       
       hStatusBar = CreateStatusWindow (%WS_CHILD OR %WS_BORDER OR %WS_VISIBLE OR %SBS_SIZEGRIP _
                                        OR %SBT_TOOLTIPS, "", hDlg, %StatusBar)
       
       DIM PresetFolder(1 to 4)
       DIM PresetCheckBox(1 to 4)
       DIM PresetCheckBoxFilter(1 to 4)
       DIM PresetCheckBoxSubDir(1 to 4)
       DIM ac(1 TO 4) AS ACCELAPI
       ac(1).fvirt = %FVIRTKEY OR %FCONTROL
       ac(1).key   = %VK_1
       ac(1).cmd   = %ButtonPreset1
       ac(2).fvirt = %FVIRTKEY OR %FCONTROL
       ac(2).key   = %VK_2
       ac(2).cmd   = %ButtonPreset2
       ac(3).fvirt = %FVIRTKEY OR %FCONTROL
       ac(3).key   = %VK_3
       ac(3).cmd   = %ButtonPreset3
       ac(4).fvirt = %FVIRTKEY OR %FCONTROL
       ac(4).key   = %VK_4
       ac(4).cmd   = %ButtonPreset4
       ACCEL ATTACH hDlg, ac() TO Retval
       
       CONTROL SET FOCUS hDlg, %ComboSearch
       IniFileRead 'Restore previous setting
       
       DIALOG SHOW MODAL hDlg, CALL PBMainProc
       
      END FUNCTION
      '______________________________________________________________________________

      Comment


      • #4

        Code:
        // GotCha.RC
        #include "Resource.h"
         
        #define MainIcon 102
        MainIcon ICON DISCARDABLE "GotCha.ico"
         
        //From SMTP PB/Win sample program ...\Sample\Internet\SMTP\SMTP.bmp
        BackGround BITMAP DISCARDABLE "smtp.bmp"
         
        VS_VERSION_INFO VERSIONINFO
        FILEOS VOS_WINDOWS32
        FILETYPE VFT_APP
        BEGIN
          BLOCK "StringFileInfo"
          BEGIN
            BLOCK "040904E4"
            BEGIN
              VALUE "FileVersion",      "3.26.00.00\000"
              VALUE "FileDescription",  "PowerBASIC search engine.\000"
              VALUE "LegalCopyright",   "FreeWare\000"
              VALUE "Comments",         "String search in PowerBASIC files.\000"
              VALUE "OriginalFilename", "GotCha.Exe\000"
              VALUE "ProductName",      "GotCha\000"
              VALUE "InternalName",     "GotCha.Exe\000"
            END
          END
        END


        [This message has been edited by Pierre Bellisle (edited May 24, 2004).]

        Comment


        • #5
          Code:
          'GotCha.ICO
          'This part, when run, will create GotCha.Ico
            
          #Compile Exe
          #Include "Win32api.inc"
          '______________________________________________________________________________
            
          Sub GetData( pCodePtr As Dword, dwSize As Dword )
              pCodePtr = CodePtr( dbdata ): dwSize = 766: Exit Sub
            
          dbdata:
           !db 000,000,001,000,001,000,032,032,016,000,000,000,000,000,232,002
           !db 000,000,022,000,000,000,040,000,000,000,032,000,000,000,064,000
           !db 000,000,001,000,004,000,000,000,000,000,128,002,000,000,000,000
           !db 000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000
           !db 000,000,000,000,128,000,000,128,000,000,000,128,128,000,128,000
           !db 000,000,128,000,128,000,128,128,000,000,192,192,192,000,128,128
           !db 128,000,000,000,255,000,000,255,000,000,000,255,255,000,255,000
           !db 000,000,255,000,255,000,255,255,000,000,255,255,255,000,000,000
           !db 000,000,000,000,000,000,000,000,000,000,000,119,000,000,000,000
           !db 000,000,000,000,000,000,000,000,000,000,007,112,006,096,000,000
           !db 000,000,000,000,000,000,000,000,000,000,119,000,099,240,000,000
           !db 000,000,000,000,000,000,000,000,000,007,112,006,063,096,000,000
           !db 000,000,000,000,000,000,000,000,000,119,000,099,246,000,000,000
           !db 000,000,000,000,000,000,000,000,007,112,006,063,096,000,000,000
           !db 000,000,000,000,000,000,000,000,119,000,099,246,000,000,000,000
           !db 000,000,000,000,000,000,000,007,112,006,063,096,000,000,000,000
           !db 000,000,007,119,119,112,000,119,000,099,246,000,000,000,000,000
           !db 000,007,119,119,119,119,119,119,006,063,096,000,000,000,000,000
           !db 007,112,000,000,000,008,119,112,015,246,000,000,000,000,000,000
           !db 112,007,000,000,000,112,008,003,096,000,000,000,000,000,000,007
           !db 007,000,119,119,119,000,112,006,240,000,000,000,000,000,000,112
           !db 000,119,238,238,238,119,000,000,000,000,000,000,000,000,000,000
           !db 119,238,255,255,255,238,112,000,135,000,000,000,000,000,000,112
           !db 238,231,102,102,119,254,231,007,007,000,000,000,000,000,000,007
           !db 238,126,119,118,102,127,238,112,008,112,000,000,000,000,007,014
           !db 238,238,238,238,118,103,254,112,112,112,000,000,000,000,000,126
           !db 238,254,238,238,231,102,127,231,000,112,000,000,000,000,000,126
           !db 255,238,238,238,238,118,127,231,000,112,000,000,000,000,000,126
           !db 239,254,238,238,238,230,111,231,000,112,000,000,000,000,000,126
           !db 255,238,239,238,238,231,111,231,000,112,000,000,000,000,000,126
           !db 239,254,238,255,238,231,111,231,000,112,000,000,000,000,000,119
           !db 239,255,254,238,238,231,111,231,000,000,000,000,000,000,007,007
           !db 238,255,254,254,238,238,126,224,112,000,000,000,000,000,000,007
           !db 126,239,255,255,254,231,238,128,000,000,000,000,000,000,000,112
           !db 119,238,255,239,239,238,231,007,000,000,000,000,000,000,000,000
           !db 007,126,238,254,238,231,119,000,000,000,000,000,000,000,000,000
           !db 000,119,126,238,231,119,000,000,000,000,000,000,000,000,000,000
           !db 007,000,119,119,119,000,112,000,000,000,000,000,000,000,000,000
           !db 000,007,000,000,000,112,000,000,000,000,000,000,000,000,000,000
           !db 000,000,000,000,000,000,000,000,000,000,000,000,000,000,255,255
           !db 255,193,255,255,255,128,255,255,255,000,255,255,254,000,255,255
           !db 252,001,255,255,248,003,255,255,240,007,255,255,224,015,255,129
           !db 192,031,254,000,000,063,248,000,000,127,240,000,000,255,224,000
           !db 003,255,192,000,007,255,192,000,003,255,128,000,003,255,128,000
           !db 001,255,000,000,001,255,000,000,001,255,000,000,001,255,000,000
           !db 001,255,000,000,001,255,000,000,001,255,000,000,003,255,000,000
           !db 003,255,128,000,007,255,128,000,007,255,192,000,015,255,224,000
           !db 031,255,240,000,063,255,248,000,127,255,254,001,255,255
          End Sub
          '______________________________________________________________________________
            
          Function PbMain
           Dim pCodePtr    As Dword
           Dim dwSize      As Dword
           Dim FF          As Long
           Dim nFileLength As Long
           Dim FileName    As String
           Dim sDataOUT    as String
            
           FileName = "GotCha.ICO"
            
           GetData pCodePtr, dwSize  '// Evt. use Peek$ etc..
           MsgBox Filename & $CRLF & "Created !!!" & $CRLF  & $CRLF & "Pointer =" & $TAB & Str$( pCodePtr ) _
                  & $CRLF & "Size =" & $TAB & Str$( dwSize ) & $CRLF & $CRLF & "Thank to Edwin Knoppert" _
                  , 266240, "ExeInExe"
            
           FF = FreeFile
           Open FileName For Binary Shared As #FF
           sDataOUT = Peek$(pCodePtr, dwSize)
           PUT #FF,, sDataOUT
           Close #FF
            
          End Function
          '______________________________________________________________________________


          [This message has been edited by Pierre Bellisle (edited February 13, 2004).]

          Comment


          • #6
            Updated to version 3.10

            Combobox-Path may have many paths separated by ;
            Find string in text,(set the combo or highlight some text and click Jump or Prev).
            Copy, Paste, Explore and Clip-filename added to context-menu.
            Etc.

            [This message has been edited by Pierre Bellisle (edited March 10, 2003).]

            Comment


            • #7
              Updated to version 3.20

              Added a Quick-View to see filenames only.
              Added an Up-Down control to navigate files in result window.
              Added Window-Search to context-menu
              Added a Editor function to context-menu that will start the editor
              of your choice with selected file.
              Some routine enhancement.
              Etc...


              [This message has been edited by Pierre Bellisle (edited March 10, 2003).]

              Comment


              • #8
                Updated to version 3.21

                Made "Find in text" case insensitive.



                [This message has been edited by Pierre Bellisle (edited February 13, 2004).]

                Comment


                • #9
                  Updated to version 3.22
                  Code:
                   
                   The Editor function is now an Editor/Help function
                     If Poffs is set it will be started with _
                      either Combo-Search text or highlighted text.
                     HLP file can be added, will also be started with _
                      either Combo-Search text or highlighted text.
                     CHM file can be added to the list.
                     Added a Replace button to Editor/Help function
                   Added 4 preset buttons that memorise Path-Combo and checkbox, _
                     to memorise a pattern, use Ctrl-Click or Ctrl-(1 to 4)
                   Added a control to copy text between Search-Combo and Find-Combo.
                   Added RunExe to contextmenu, exe must exist.
                   Added Command to contextmenu (Cmd.exe under NT).
                   Added ShakeDialog for error notification.
                   Blank Line option is now dynamic.
                   Many behavior enhancement.


                  [This message has been edited by Pierre Bellisle (edited February 13, 2004).]

                  Comment


                  • #10
                    Updated to version 3.25 2004-02-13

                    "Whole" checkbox added to find whole word.
                    Added file with ".h" extention in search.
                    "File checkBox" added to be able to do a "File ANDed" search instead of a "Line ANDed search".
                    Option "Exact search" now use SpaceShrink function,
                    meaning searching for
                    Code:
                     "  X   Y " will find " X Y " or " X        Y "
                    Bug corrected, replaced invalid "EOF(FileNo)" call.
                    Last selected preset button will be bold.
                    Command$ goes to search combobox.
                    Control-Down and Control-Up support added in EDM32



                    [This message has been edited by Pierre Bellisle (edited February 13, 2004).]

                    Comment


                    • #11
                      Updated to version 3.26 - 2004-05-24

                      Added a function for calling .col help file, like MSDN, thank to Kev Peel
                      Added a label to show current line/column/selection
                      Different bacground color when in the "Result" window
                      Becose Gotcha use left double click for switching view window instead of selecting word,
                      the function ctmMouseLButtonDblClk in EDM32.inc should be modified (See GotCha.bas).


                      Pierre

                      [This message has been edited by Pierre Bellisle (edited May 24, 2004).]

                      Comment

                      Working...
                      X