Announcement

Collapse
No announcement yet.

Multiple Open File Dialog again

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

  • Multiple Open File Dialog again

    The multiple file select "Open file dialog" works great now! (Thanks!)

    BUt now i have another issue.
    I'm putting all of the files into a ListView and that works great but I want to determine if a file has already been added.
    That piece of the code broke when I made it open multiple files:
    It basically states that if you only open one file, it now determines that file is added whether it is or is not.


    And multiple files? It doesn't even check, or does not return anythign if the multiple file is there.

    Would there be a better way to do an Array Scan with the Listview? Since it is disaplying the actual files that were opened?


    Code:
                            g_Result = MyOpenFileDialog(ByVal hDLg,_
                                                        ByVal Caption,_
                                                        FileSpec,_
                                                        g_CurrWorkingDir,_
                                                        ByVal Filter,_
                                                        ByVal DefExtension,_
                                                        lStyle)
                            lResult = Tally(FileSpec,Chr$(0))
                            If lResult <> 0 Then  'Parse out the multiple files
                               CurrentDir = Parse$(FileSpec,Chr$(0),1)
                               FileSpec = Right$(FileSpec,Len(FileSpec) - Instr(FileSpec,Chr$(0))) 'REMOVE the directory
                               If IsFalse g_FileIndex Then g_FileIndex = 1 'Prevent GPF if at zero
    
                               For lLoop = g_FileIndex To lResult
                                   g_Files(lLoop) = CurrentDir & "\" & Parse$(FileSpec,Chr$(0),lLoop)
                                   ListBox Add hDlg, %IDLISTBOX1, g_Files(lLoop)
                                   g_FileIndex = lLoop 'Keep index up to date
                               Next
    
                            Else   'Add the single file but First make sure it's not in the list already
                               Incr g_FileIndex
                               g_Files(g_FileIndex) = FileSpec
                               ListBox Add hDlg, %IDLISTBOX1, g_Files(g_FileIndex)
                            End If
                            
                               Array Scan g_Files(), Collate Ucase, = FileSpec, To DuplicateCheck
                               If DuplicateCheck Then
                                   MsgBox "The file " & g_Files(DuplicateCheck) & " is already added", %MB_ICONINFORMATION,g_szCCS
                                   Exit Function
                               End If
    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Well that didn't take long to read what I posted and find my bug..

    And if it's NOT my bug it sure is another one.....

    For g_FileIndex = 1 to lResult
    g_FileIndex = lLoop 'Keep index up to date
    Next


    OH that's a doozy hehe....

    Let me try this again and get back to you all


    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      Lets try another approach....
      (It's ListBox not ListView by the way)

      My files are opened and put into the ListBox, and I don't really care what's in the ARRAY of files until the COMPILE button is pressed on the application.

      That being said, would it be easier to just put the files into the Listbox, then if MORE are added do a scan of the Listbox for a duplicate file?

      I don't want duplicate files being displayed, and I can read the data into the array when COMPILE is pressed, from the ListBox..

      Hmmmmm just style at this point, what are your thoughts on this?

      Is it easier to maintain the array and not worry about the Listbox or better to maintain the ListBox for viewability purposes (So dupes aren't shown in the box)??


      Scott

      ------------------
      Scott
      mailto:[email protected][email protected]</A>
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        I suggest using Sendmessage with LB_FINDSTRINGEXACT to see if the
        file already has been added. Fast enough for most operations.
        Remember to set indexStart to -1 for checking all items in the list.
        (I created a nice bug for a client via this once, by setting it to
        zero, so first item never was checked..

        This way, you shouldn't even need any arrays - just check if the file
        is in the list and add it if not. Use the listbox as "visual array",
        so to speak..


        ------------------

        Comment


        • #5
          Scott,

          I take the approach that potential problems should be corrected
          as close to their generation as possible. This prevents potential
          errors from creeping in on me.

          In the Listboxes which I am using in my programs for File and
          Field selections, I check for duplicates immediately an entry occurs,
          or as soon as the information becomes available to my program.

          I don't permit errors to occur that the user can see if it is
          possible to prevent it. I use one array to hold my data items. I use
          another array of indexes which corresponds to which data I want to
          show in my Listboxes. That permits me to more easily allow the user
          to select and re-order listbox items. I never allow the sorting of
          strings by the list box itself.

          I just saw Borje's posting. Different techniques for different
          programmers. There is always another way to skin your Felis domesticus.

          Regards,

          ------------------
          [email protected]
          :) IRC :)

          Comment


          • #6
            > There is always another way to skin your Felis domesticus.

            Sure is. Put 10 programmers to write 3 identical lines of code
            and you'll end with 10 different solutions. Not possible? For
            programmers, everything is possible..

            BTW, I often use arrays for this purpose myself. In some cases,
            using the listbox and LB_FINDSTRINGEXACT calls before adding can
            be sufficiant though.


            ------------------

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎