
    ***************************** FILESRCH *********************************
    FUNCTION FILESRCH( cFilename, cCurDir , cFilefound, lSubDirs )
    LOCAL bFsearch :=  {|a| upper(a[F_NAME])==UPPER(cFilename) }
    LOCAL aTempDir, i, j
    *-----------------------------------------------------------------------
    aTempDir :=  Directory(cCurDir+"\"+cFilename)
    IF ASCAN(aTempDir,bFsearch) != 0         && Gefunden / Search current directory
       cFilefound := cCurDir + "\"+ UPPER(cFilename)
       RETURN (cFilefound)                   // gefunden!
    ENDIF
    IF lSubDirs
       aTempDir := Directory(cCurDir+"\*.","D")     && Get subdirectories
       IF !Empty(aTempDir)                          && Search subdirectories
          IF !Empty(aTempDir[1,F_NAME])                && Search subdirectories
             IF Empty(cFilefound);                     // noch nichts gefunden
                .AND. 'D' $ aTempDir[1,F_ATTR]         // nur Dir's
                IF atempDir[1,F_NAME]="."                 && Look at first subdirectory
                     IF LEN(aTempDir)=2                   && Possibly no subdirectories
                        RETURN (cFilefound)               // Dir leer
                     ENDIF
                     i=3
                ELSE
                     i=1
                ENDIF
                FOR j = i TO LEN(aTempDir)                && Start searching subdirectories
                    IF 'D' $ aTempDir[j,F_ATTR]           // nur Dir's
                       cCurDir=cCurDir+"\"+aTempDir[j,F_NAME]
                       filesrch(cFilename, cCurDir, @cFilefound, @lSubDirs) && Recursive call
                       cCurDir=SUBSTR(cCurDir,1,RAT("\",cCurDir)-1)
                    ENDI
                    IF !empty(cFilefound)
                       exit
                    ENDI
                NEXT
             ENDIF
          ENDIF
       ENDIF
    ENDI
    RETURN (cFilefound)
