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

list a single directory with filtering routines

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

  • list a single directory with filtering routines

    Here is program to list a single directory and also filter files listed by input and by extension, whether executable files or unknown file types or known file types.

    The command line can contain only a directory(c:\pbwin80) or a directory with wildcard files(c:\pbwin80\*.bas"

    This program maybe could make a good file retriever if altered.

    The original idea was to list files to be opened by another program where file types are known and used.

    This is the first good jab at such a program for me.
    Hopefully the next version will include either more command line options or
    make use of environment variables.

    I have yet to put in the date and time of the files, which i wanted to get the main part of the program running first.

    The program uses environment variable "PATHEXT" to determine executable extensions. Also the program checks for a environment variable "EXEEXTENSIONS" you can set with to have additional executable extensions no in the environmental variable "PATHEXT".

    I have not made up mind on using environmental variables extensively to define variables for this program, but it may seem like a good choice unless somebody else changes my mind.

    It would be nice to get a listing of multiple particular file listing only, an example would be if you had word and pdf and rtf files in a directory with other files, you could select something like ".DOC .PDF .RTF" as a filter to keep only those files in the listing and exclude all other files.

    once this program is done, i want to have a program to retrieve files from directories.

    this liisting does not have a version in it but i will add one to the website
    this will be 1.01

    you can get the newest version of the program at
    http://pdptemp.dyndns.org/zipcode



    Code:
    program changed see next post
    Last edited by Paul Purvis; 25 Feb 2008, 10:01 PM.
    p purvis

  • #2
    newer version

    updated code
    Last edited by Paul Purvis; 3 Mar 2008, 04:19 PM.
    p purvis

    Comment


    • #3
      new version

      Code:
      'REM EXTRUNFL.BAS
      ' program will read a single directory in and view it in a dialog
      ' choices made are whether to open the program or print it if the extension is listed in file types."
      'version 1.05
      #COMPILE EXE    'pbwin 8.04
      #DIM ALL
      #INCLUDE "WIN32API.INC"
      %IDD_DIALOG1      =  101
      %IDC_TEXTBOX1     = 1001
      %IDC_LISTBOX1     = 1002
      %IDC_BUTTON1      = 1003
      %IDC_BUTTON2      = 1004
      %IDC_BUTTON3      = 1005
      %IDC_LABEL1       = 1009
      %IDC_OPTION1      = 1011
      %IDC_OPTION2      = 1012
      %IDC_BUTTON4      = 1013
      %IDC_BUTTON5      = 1014
      %IDC_LABEL2       = 1015
      %IDC_LABEL3       = 1016
      %IDC_LABEL4       = 1017
      %IDC_LABEL5       = 1018
      %IDC_OPTION3      = 1019
      %IDC_BUTTON6      = 1006
      %IDC_BUTTON7      = 1007
      %IDC_BUTTON8      = 1008
      %IDC_LABEL6       = 1020
      
      
      
      DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
      DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
      
      GLOBAL gamainarray() AS STRING
      GLOBAL gdialogbox1 AS DWORD
      GLOBAL gselectedfile AS STRING
      GLOBAL gsdirectoryget AS STRING
      GLOBAL glmainarrayitems AS LONG
      GLOBAL Glsortdirection AS LONG
      GLOBAL gaworkarray() AS STRING
      GLOBAL glworkarrayitems AS LONG
      GLOBAL Gaundoarray() AS STRING
      GLOBAL glundoarrayitems AS LONG
      GLOBAL glfilterleave AS LONG
      GLOBAL glfilterremove AS LONG
      GLOBAL glfilterundo AS LONG
      GLOBAL gsfiltertext AS STRING
      GLOBAL gsenvironpathext AS STRING
      GLOBAL gsenvironextrunflexeexts AS STRING
      GLOBAL gsknownfiletypes AS STRING
      GLOBAL gscullstring AS STRING
      GLOBAL gsversion AS STRING
      GLOBAL glrestart AS LONG
      GLOBAL gsfileinfo AS STRING
      GLOBAL gsdirectory AS STRING
      
      
      FUNCTION  filedatetimeLOCAL(somefile AS STRING) AS STRING
      LOCAL hFile         AS DWORD
      LOCAL FindData   AS WIN32_FIND_DATA
      LOCAL AMPM AS STRING
      LOCAL mytimestyle AS STRING
      LOCAL temp AS LONG
      LOCAL tmpSize AS QUAD                ' QUAD, in case of huge files...
      LOCAL sizeoffile AS STRING
      LOCAL FileAttribute AS STRING
      LOCAL Loct AS FileTime
      LOCAL Syst AS SystemTime
      LOCAL sfiledatetime AS STRING
      
      hFile = FindFirstFile(BYVAL STRPTR(SomeFile), FindData) 'Get file data, file time included
      IF hFile <> %INVALID_HANDLE_VALUE THEN 'We have an handle coresponding to the file
            tmpSize = FindData.nFileSizeHigh * (%MAXDWORD + 1) + FindData.nFileSizeLow
            sizeoffile=RIGHT$("                 "+FORMAT$(tmpSize, "#,###"),17)+" "
            ELSE
            sizeoffile=""
      END IF
      
      'creationtime
      'FileTimeToLocalFileTime FindData.ftCreationTime, LocT
      'lastwritetime
      'FileTimeToLocalFileTime FindData.ftLastWriteTime, Loct
      'use lastwritetime
      FileTimeToLocalFileTime FindData.ftLastWriteTime, Loct
      FileTimeToSystemTime(locT, sysT)
      ampm="a"
         'rem use non military time
            IF Syst.wHour<12 THEN
              temp=Syst.wHour
              IF temp=0 THEN temp=12
              mytimestyle=RIGHT$("00" + TRIM$(STR$(temp)),2) + ":" + _
              RIGHT$("00" + TRIM$(STR$(Syst.wMinute)),2) + ":" + _
              RIGHT$("00" + TRIM$(STR$(Syst.wSecond)),2) + _
               ampm+ " "+CHOOSE$(SysT.wDayOfWeek + 1, "sun", "mon", "tue", "wed", "thu", "fri", "sat")
            ELSE
             ampm="p"
             temp=Syst.wHour-12
             IF temp=0 THEN temp=12
             mytimestyle=RIGHT$("00" + TRIM$(STR$(temp)),2) + ":" + _
             RIGHT$("00" + TRIM$(STR$(Syst.wMinute)),2) + ":" + _
             RIGHT$("00" + TRIM$(STR$(Syst.wSecond)),2) + _
              ampm+ " "+CHOOSE$(SysT.wDayOfWeek + 1, "sun", "mon", "tue", "wed", "thu", "fri", "sat")
           END IF
      
      FileAttribute = ""
             IF (FindData.dwFileAttributes AND %ReadOnly) THEN FileAttribute = FileAttribute & "R" ELSE FileAttribute = FileAttribute & " "
             IF (FindData.dwFileAttributes AND %Hidden)   THEN FileAttribute = FileAttribute & "H" ELSE FileAttribute = FileAttribute & " "
             IF (FindData.dwFileAttributes AND %System)   THEN FileAttribute = FileAttribute & "S" ELSE FileAttribute = FileAttribute & " "
             IF (FindData.dwFileAttributes AND %Archive)  THEN FileAttribute = FileAttribute & "A" ELSE FileAttribute = FileAttribute & " "
       fileattribute=fileattribute+" "
      
      sfiledatetime=RIGHT$("00"+TRIM$(STR$(Syst.wMonth)),2) + _
                   "-" +RIGHT$("00"+TRIM$(STR$(Syst.wDay)),2) + _
                   "-" +RIGHT$("0000"+TRIM$(STR$(Syst.wYear)),4) + _
                   " " + mytimestyle+"  "
      IF  Syst.wYear=1601 THEN
           sfiledatetime="00-00-0000 00:00:00a     "
      END IF
      FUNCTION=sfiledatetime+  " size= "+TRIM$(sizeoffile)
      FindClose(hFile)
      END FUNCTION
      
      
      
      FUNCTION cullfileextensionlisting() AS LONG
      LOCAL TXT$,TEST$
      LOCAL I,J,K AS LONG
      LOCAL result1&
          CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
          TXT$=""
          IF Result1& >= 0& THEN
            LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
            LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
           END IF
          J=-1
           FOR I=0& TO glworkarrayitems-1&
                  IF INSTR(gaworkarray(I),".")<1& THEN
                      INCR J:gaworkarray(J)=gaworkarray(I)
                   ELSE
                   TEST$=STRREVERSE$(gaworkarray(I))
                      K=INSTR(TEST$,".")
                      IF INSTR(UCASE$(gscullstring),UCASE$(RIGHT$(gaworkarray(I),K)))=0& THEN INCR J:gaworkarray(J)=gaworkarray(I)
                  END IF
           NEXT I
                 glworkarrayitems=J+1&
                 REDIM PRESERVE gaworkarray(0& TO glworkarrayitems-1&)
                 LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                 REM redisplay in listbox
                 FOR I=0 TO glworkarrayitems-1&
                 LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
                 NEXT I
                 IF LEN(TXT$)>0& THEN
                   FOR I=0 TO glworkarrayitems-1&
                     IF gaworkarray(I)=TXT$ THEN LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I&+1&:EXIT IF
                   NEXT I
                 LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                 END IF
          CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      
      FUNCTION keepunknownfileextensionlisting() AS LONG
      LOCAL TXT$,TEST$
      LOCAL I,J,K AS LONG
      LOCAL result1&
          CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
          TXT$=""
          IF Result1& >= 0& THEN
            LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
            LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
           END IF
          J=-1
           FOR I=0 TO glworkarrayitems-1&
                  IF INSTR(gaworkarray(I),".")>0& THEN
                   TEST$=STRREVERSE$(gaworkarray(I))
                      K=INSTR(TEST$,".")
                      IF INSTR(UCASE$(gscullstring),UCASE$(RIGHT$(gaworkarray(I),K)))>1& THEN INCR J:gaworkarray(J)=gaworkarray(I)
                  END IF
           NEXT I
                 glworkarrayitems=J+1&
                 REDIM PRESERVE gaworkarray(0& TO glworkarrayitems-1&)
      
                 LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                  REM redisplay in listbox
                 FOR I=0 TO glworkarrayitems-1&
                 LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
                 NEXT I
                 IF LEN(TXT$)>0& THEN
                   FOR I=0 TO glworkarrayitems-1&
                     IF gaworkarray(I)=TXT$ THEN LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I&+1&:EXIT IF
                   NEXT I
                 LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                 END IF
          CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      
      FUNCTION usethefile(sfiletoopen AS STRING) AS LONG
        DIM I AS LONG
        LOCAL zsText AS ASCIIZ * 256
        zstext=sfiletoopen
        I=ShellExecute(%NULL , "open",zstext,BYVAL %NULL, CURDIR$, %SW_SHOWNORMAL)
        IF I<33& THEN MSGBOX "The selected item cannot be executed or opened using this method",,"Extrunfl message"
      
      END FUNCTION
      
      
      FUNCTION printthefile(sfiletoopen AS STRING) AS LONG
        DIM I AS LONG
        LOCAL zsText AS ASCIIZ * 256
        zstext=sfiletoopen
        ShellExecute(%NULL , "print",zstext,BYVAL %NULL, CURDIR$, %SW_SHOWNORMAL)
        IF I<33& THEN MSGBOX "The selected item cannot be printed using this method",,"Extrunfl message"
      
      END FUNCTION
      
      
      FUNCTION getfilefromlist() AS STRING
          LOCAL Result1&, Result2&
          LOCAL I AS LONG
          LOCAL TXT$
          CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
          gselectedfile=""
          TXT$=""
          IF Result1& >= 0& THEN
            LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
            LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
           END IF
      FUNCTION=TXT$
      END FUNCTION
      
      
      FUNCTION restorefilelist() AS LONG
           LOCAL Result1&, Result2&
           LOCAL I  AS LONG
           LOCAL TXT$
           CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
           TXT$=""
                   IF Result1& >= 0& THEN
                      LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
                      LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
                    END IF
      
          REDIM gaworkarray(0 TO glmainarrayitems-1&)
          FOR I=0& TO glmainarrayitems-1&
              gaworkarray(I)=gamainarray(I)
              NEXT I
         glsortdirection=1&
         glworkarrayitems=glmainarrayitems
         LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
         FOR I=0 TO glworkarrayitems-1&
          LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
         NEXT I
         IF LEN(TXT$)>0& THEN
          FOR I=0 TO glworkarrayitems-1&
          IF gaworkarray(I)=TXT$ THEN LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I&+1&:EXIT
          NEXT I
         END IF
         CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      
      FUNCTION applyfilter() AS LONG
          IF glfilterundo=0& THEN IF glworkarrayitems<1& THEN EXIT FUNCTION
           LOCAL Result1&, Result2&
           LOCAL I, J AS LONG
           LOCAL TXT$
           CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
           TXT$=""
                   IF Result1& >= 0& THEN
                      LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
                      LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
                    END IF
      
      
             LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
             FOR I=1& TO 10&
             LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, " "
             NEXT I
             LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, "  please wait while filter is being applied"
      
                  IF glfilterundo THEN
                     glworkarrayitems=glundoarrayitems
                     REDIM gaworkarray(0& TO glworkarrayitems-1&)
                     FOR I=0 TO glworkarrayitems-1&
                         gaworkarray(I)=gaundoarray(I)
                     NEXT I
      
                     GOTO RELISTUNDOARRAY
                END IF
      
                IF glfilterleave+glfilterremove THEN
                     glundoarrayitems=glworkarrayitems
                     REDIM gaundoarray(0& TO glundoarrayitems-1&)
                     FOR I=0 TO glworkarrayitems-1&
                         gaundoarray(I)=gaworkarray(I)
                     NEXT I
                END IF
      
                 J=-1&
                 FOR I=0 TO glworkarrayitems-1&
                    IF glfilterleave THEN
                        IF INSTR(UCASE$(gaworkarray(I)),UCASE$(gsfiltertext))>0& THEN INCR J:gaworkarray(J)=gaworkarray(I)
                     ELSE
                     IF glfilterremove THEN
                         IF INSTR(UCASE$(gaworkarray(I)),UCASE$(gsfiltertext))=0& THEN INCR J:gaworkarray(J)=gaworkarray(I)
                     END IF
                    END IF
      
                 NEXT I
                 glworkarrayitems=J+1&
                 REDIM PRESERVE gaworkarray(0& TO glworkarrayitems-1&)
      
           RELISTUNDOARRAY:
      
                 LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                 REM redisplay in listbox
                 FOR I=0 TO glworkarrayitems-1&
                 LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
                 NEXT I
                 LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                 IF LEN(TXT$)>0& THEN
                   FOR I=0 TO glworkarrayitems-1&
                     IF gaworkarray(I)=TXT$ THEN LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I&+1&:EXIT IF
                   NEXT I
                     LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                  END IF
          CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      FUNCTION sortfilelist() AS LONG
          LOCAL Result1&, Result2&
          LOCAL I AS LONG
          LOCAL TXT$,hn&
          LOCAL szItem      AS ASCIIZ * %MAX_PATH
              CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCURSEL, 0, 0 TO Result1&
              TXT$=""
                    IF Result1& >= 0& THEN
                      LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, Result1&+1&
                      LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO TXT$
                    END IF
      
                CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCOUNT, 0, 0 TO Result2&
                 IF Result2& >= 0& THEN
      
                 LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                 FOR I=1& TO 10&
                 LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, " "
                 NEXT I
                 LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, "        please wait while list is being sorted"
                 IF glsortdirection=0& THEN
                    glsortdirection=1&
                    ARRAY SORT gaworkarray(), COLLATE UCASE, DESCEND
                       ELSE
                    glsortdirection=0&
                    ARRAY SORT gaworkarray(), COLLATE UCASE, ASCEND
                 END IF
                 LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                 FOR I=0 TO result2&-1&
                  LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
                 NEXT I
                  LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                   IF LEN(TXT$)>0& THEN
                   FOR I=0& TO result2&-1&
                     IF gaworkarray(I)=TXT$ THEN LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I&+1&:EXIT
                   NEXT I
                 END IF
              END IF
              CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      
      FUNCTION regetdirlisting() AS LONG
          REGISTER  I AS LONG ,K AS LONG
          LOCAL dwCount AS DWORD
          LOCAL szDir AS ASCIIZ*255
          LOCAL TXT$
          LOCAL sfi AS SHFILEINFO
          LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
          szdir=gsdirectoryget
          CONTROL SET SIZE  gdialogbox1, %IDC_LISTBOX1,-1, -1
          LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
          CALL DlgDirList(gdialogbox1,szdir,%IDC_LISTBOX1,%IDC_LABEL1, %DDL_READONLY OR %DDL_READWRITE OR %DDL_ARCHIVE)
          REDIM gamainarray (0& TO 0&)
          REDIM gaworkarray (0& TO 0&)
          REDIM gaundoarray (0& TO 0&)
          CONTROL SEND gdialogbox1, %IDC_LISTBOX1, %LB_GETCOUNT, 0, 0 TO dwcount
          glmainarrayitems=dwcount
          glworkarrayitems=glmainarrayitems
          glundoarrayitems=glmainarrayitems
          gsknownfiletypes=""
          REDIM gamainarray(0& TO glmainarrayitems-1&)
          glundoarrayitems=glmainarrayitems
          REDIM gaundoarray(0& TO glundoarrayitems-1&)
          REDIM gaworkarray(0& TO glworkarrayitems-1&)
                  FOR I=0 TO glmainarrayitems-1&
                   LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, I+1&
                   LISTBOX GET TEXT gdialogbox1, %IDC_LISTBOX1 TO gamainarray(I)
                   gaundoarray(I)=TRIM$(gamainarray(I))
                   gaworkarray(I)=gaundoarray(I)
                     IF INSTR(gaworkarray(I),".")>0& THEN
                     txt$=STRREVERSE$(gaworkarray(I))
                        K=INSTR(txt$,".")
                        txt$=UCASE$(RIGHT$(gaworkarray(I),K))
                        IF INSTR(gsknownfiletypes,txt$)=0& THEN
                           SHGetFileInfo "*"+txt$, %FILE_ATTRIBUTE_NORMAL, sfi, LEN(sfi), %SHGFI_USEFILEATTRIBUTES OR %SHGFI_TYPENAME
                          IF LEN(TRIM$(sfi.szTypeName))>0& THEN gsknownfiletypes=gsknownfiletypes+" "+txt$
                        END IF
                     END IF
                  NEXT I
                 ARRAY SORT gamainarray(), COLLATE UCASE, ASCEND
                 ARRAY SORT gaundoarray(), COLLATE UCASE, ASCEND
                 ARRAY SORT gaworkarray(), COLLATE UCASE, ASCEND
                  LISTBOX RESET gdialogbox1, %IDC_LISTBOX1
                  FOR I=0 TO glworkarrayitems-1&
                  LISTBOX ADD gdialogbox1, %IDC_LISTBOX1, gaworkarray(I)
                  NEXT I
                glsortdirection=0&
                CONTROL SET SIZE  gdialogbox1, %IDC_LISTBOX1,428, 325
                LISTBOX SELECT gdialogbox1, %IDC_LISTBOX1, 1&
                CONTROL SET FOCUS gdialogbox1, %IDC_LISTBOX1
      END FUNCTION
      
      FUNCTION PBMAIN()
          gsversion="1.05"
          LOCAL COMMANDLINE AS STRING
      
          ' setup some initial values for program
          commandline=TRIM$(COMMAND$)
          gsdirectoryget=commandline
          IF LEN(gsdirectoryget)=0 THEN
              MSGBOX "This program requires a command tail"+$CRLF+ _
                     "      providing a directory to list."+$CRLF+$CRLF+ _
                     "             Aborting!"+$CRLF+$CRLF+_
                     "    EXTRUNFL version "+gsversion,%MB_ICONINFORMATION,"EXTRUNFL - ERROR"
              EXIT FUNCTION
           END IF
      
          STARTOVER:
          glsortdirection=1&
          glfilterleave=0&
          glfilterremove=0&
          gsenvironpathext=ENVIRON$("PATHEXT")
          gsenvironextrunflexeexts=ENVIRON$("extrunflexeexts")
      
          ShowDIALOG1 %HWND_DESKTOP
          IF glrestart=1& THEN glrestart=0&:GOTO STARTOVER
      END FUNCTION
      
      CALLBACK FUNCTION buttoncallbackleave() AS LONG
      glfilterleave=1&
      glfilterremove=0&
      glfilterundo=0&
      END FUNCTION
      
      CALLBACK FUNCTION buttoncallbackremove() AS LONG
      glfilterleave=0&
      glfilterremove=1&
      glfilterundo=0&
      END FUNCTION
      
      CALLBACK FUNCTION buttoncallbackundo() AS LONG
      glfilterleave=0&
      glfilterremove=0&
      glfilterundo=1&
      END FUNCTION
      
      
      
      CALLBACK FUNCTION ShowDIALOG1Proc()
      LOCAL COUNT&
          SELECT CASE AS LONG CBMSG
              CASE %WM_INITDIALOG
                gselectedfile=getfilefromlist()
                   IF LEN(gselectedfile)>0& THEN
                      gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                      CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                      CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                   END IF
      
               CASE %WM_NCACTIVATE
                  STATIC hWndSaveFocus AS DWORD
                  IF ISFALSE CBWPARAM THEN
                      hWndSaveFocus = GetFocus()
                  ELSEIF hWndSaveFocus THEN
                      SetFocus(hWndSaveFocus)
                      hWndSaveFocus = 0
                  END IF
      
              CASE %WM_COMMAND
                  SELECT CASE AS LONG CBCTL
                      CASE %IDC_TEXTBOX1
      
                      CASE %IDC_LISTBOX1
                               IF CBCTLMSG = 1& THEN
                                gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                                END IF
      
                          CASE %IDC_BUTTON1
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                          gselectedfile=getfilefromlist()
                             IF LEN(gselectedfile)>0 THEN
                                usethefile(gselectedfile)
                             END IF
                          END IF
      
                      CASE %IDC_BUTTON2
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                            gselectedfile=getfilefromlist()
                             IF LEN(gselectedfile)>0 THEN
                                printthefile(gselectedfile)
                             END IF
                          END IF
      
                      CASE %IDC_BUTTON3
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                             CONTROL GET TEXT  gdialogbox1, %IDC_TEXTBOX1 TO gsfiltertext
                             gsfiltertext=TRIM$(gsfiltertext)
                             IF LEN(gsfiltertext)>0 THEN
                              IF (glfilterleave+glfilterremove+glfilterundo)>0& THEN
                                applyfilter
                                gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                               END IF
                            END IF
      
                          END IF
      
                      CASE %IDC_BUTTON4
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                          ' glrestart=1&
                          ' DIALOG END gdialogbox1
                           regetdirlisting
                          END IF
      
                      CASE %IDC_BUTTON5
                           IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                              sortfilelist
                               gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                           END IF
      
                      CASE %IDC_BUTTON6
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                            gscullstring=gsenvironpathext+" "+gsenvironextrunflexeexts
                            cullfileextensionlisting
                             gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                          END IF
      
                      CASE %IDC_BUTTON7
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1& THEN
                            gscullstring=gsenvironpathext+gsknownfiletypes+gsenvironextrunflexeexts
                            keepunknownfileextensionlisting
                             gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                          END IF
      
                      CASE %IDC_BUTTON8
                          IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            gscullstring=gsenvironpathext+gsknownfiletypes+gsenvironextrunflexeexts
                            cullfileextensionlisting
                              gselectedfile=getfilefromlist()
                                gsfileinfo=FILEDATETIMELOCAL(gsdirectory & gselectedfile)
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL2,gselectedfile
                                CONTROL SET TEXT gdialogbox1, %IDC_LABEL3,gsfileinfo
                                gselectedfile=""
                          END IF
      
                      CASE %IDC_LABEL1
      
                  END SELECT
          END SELECT
      END FUNCTION
      
      
      
      
      FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
          LOCAL lRslt AS LONG
          LOCAL hDlg  AS DWORD
          LOCAL szDir AS ASCIIZ*255
      
          DIALOG FONT "Courier New",8
      
          DIALOG NEW hParent, "EXTRUNFL", 79, 70, 430, 360, %DS_MODALFRAME OR _
          %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
      
          CONTROL ADD LISTBOX, hDlg, %IDC_LISTBOX1, , 0, 11, 428, 325, %WS_CHILD _
              OR %WS_VISIBLE OR %WS_HSCROLL OR %WS_VSCROLL OR _ _
              %LBS_NOTIFY  , %WS_EX_CLIENTEDGE OR %WS_EX_LEFT 'OR %WS_EX_LTRREADING _
                            'OR %WS_EX_RIGHTSCROLLBAR
      
          CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "", 1, 1, 143, 10
          CONTROL ADD OPTION,  hDlg, %IDC_OPTION1, "show", 144, 2, 28, 8,, CALL buttoncallbackleave()
          CONTROL ADD OPTION,  hDlg, %IDC_OPTION2, "hide", 172, 2, 30, 8,, CALL buttoncallbackremove()
          CONTROL ADD OPTION,  hDlg, %IDC_OPTION3, "undo", 202, 2, 28, 8,, CALL buttoncallbackundo()
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON3, "do it", 231, .75, 40, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON4, "restart", 275, .75, 29, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON5, "sort", 308, .75, 20, 10
      
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "use file", 334, .75, 46, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON2, "print file", 382, .75, 46, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON6, "remove executables", 210, 350, 78, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON7, "known", 356, 350, 30, 10
          CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON8, "unknown", 394, 350, 32, 10
          CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "Error reading directory/folder "+gsdirectoryget, 1, 332, 425, 10
      
          'rem not using the two below labels at this time to display file time
          CONTROL ADD LABEL,   hDlg, %IDC_LABEL2, "File Name", 1, 341, 425, 10
          CONTROL ADD LABEL,   hDlg, %IDC_LABEL3, "File date time and size", 1, 350, 188, 10
      
      
          CONTROL ADD LABEL,   hDlg, %IDC_LABEL5, "use file types:", 294, 352, 62,10
      
          gdialogbox1=hdlg
          regetdirlisting
          CONTROL GET TEXT hdlg, %IDC_LABEL1 TO gsdirectory
          IF INSTR(gsdirectory,"Error reading directory/folder")>0& THEN
              gsdirectory=""
              ELSE
              gsdirectory=gsdirectory+"\"
          END IF
          DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
          FUNCTION = lRslt
      END FUNCTION
      Last edited by Paul Purvis; 9 Mar 2008, 10:21 PM.
      p purvis

      Comment


      • #4
        an error is located after the shellexecute command
        rather than

        IF I < 32&

        should be

        IF I < 33&

        fixed in the above code

        sorry just saw there error, the program may still run as was first written

        paul
        Last edited by Paul Purvis; 9 Mar 2008, 10:22 PM.
        p purvis

        Comment

        Working...
        X