Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    How to sort with FSO?

    Hello,
    I'm wondering how I can order a list of folders with File System Object,
    but a little more then that,

    I've got a list of folders that have user id numbers for names, so I've build a simpler data base function to show the name of the user insted of the number. I *think* what I need to do it load it up into an array, and sort it from there, but I've never trying sorting an array.

    any ideas?

    thanks in advance for your time!
    -Ken

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ok!
    I found this script:

    http://www.4guysfromrolla.com/demos/2dsort.asp

    which works fine.
    but I'm not exactly sure how to load all my data into a 2 dimensional array.

    any ideas?

    thanks in advance for your time!
    -Ken

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ah, and there we go:-)

    incase anyone needs this, here it is:

    PHP Code:
    <%
        
    Set fso Server.CreateObject("Scripting.FileSystemObject")
        
    Set rootFolder fso.GetFolder(Server.MapPath("/admin/orders/artwork/"))

        
    Dim arrDualArray()
        
    Dim subFolders
        Set subFolders 
    rootFolder.SubFolders
        numFolders 
    subFolders.Count
        ReDim arrDualArray
    (numFolders2)

    ' gather data into array
        numArrayIndex = 0
        For Each folder in subFolders
            arrDualArray( numArrayIndex, 0 ) = GetClientNameByID( folder.Name )
            arrDualArray( numArrayIndex, 1 ) = folder.Name
            numArrayIndex = numArrayIndex + 1
        Next

    start sort
    Sub DualSorter
    byRef arrArrayDimensionToSort )
        
    Dim rowjStartingKeyValueStartingOtherValue_
            NewStartingKey
    NewStartingOther_
            swap_pos
    OtherDimension
        
    Const column 1
        
        
    ' Ensure that the user has picked a valid DimensionToSort
        If DimensionToSort = 1 then
            OtherDimension = 0
        ElseIf DimensionToSort = 0 then
            OtherDimension = 1
        Else
            '
    Shootinvalid value of DimensionToSort
            Response
    .Write "Invalid dimension for DimensionToSort: " _
                           
    "must be value of 1 or 0."
            
    Response.End
        End 
    If
        
        For 
    row 0 To UBoundarrArraycolumn ) - 1
        
            StartingKeyValue 
    arrArray rowDimensionToSort )
            
    StartingOtherValue arrArray rowOtherDimension )
            
            
    NewStartingKey arrArray rowDimensionToSort )
            
    NewStartingOther arrArray rowOtherDimension )
            
            
    swap_pos row
            
            
    For row 1 to UBoundarrArraycolumn )
                If 
    arrArray jDimensionToSort ) < NewStartingKey Then
                    swap_pos 
    j
                    NewStartingKey 
    arrArray jDimensionToSort )
                    
    NewStartingOther arrArray jOtherDimension )
                
    End If
            
    Next
            
            
    If swap_pos <> row Then
                arrArray 
    swap_posDimensionToSort ) = StartingKeyValue
                arrArray 
    swap_posOtherDimension ) = StartingOtherValue
                
                arrArray 
    rowDimensionToSort ) = NewStartingKey
                arrArray 
    rowOtherDimension ) = NewStartingOther
                
            End 
    If    
        
    Next
    End Sub


    call DualSorter
    (arrDualArray0)

    For 
    LBound(arrDualArrayto UBound(arrDualArray)
      
    Response.Write arrDualArray(i0) & " - "
      
    Response.Write arrDualArray(i1) & "<BR>"
    Next
    %> 
    -Ken

  • #4
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    For what do i need FSO?

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    http://www.tutorial-web.com/asp/fso/

    The FileSystem Object is the object that is used to manipulate the filesystem in Active Server Pages. Moving files, opening and reading text files, and looking at drive space are a few of the many functions of the FileSystem Object. The FileSystem Object actually contains five objects: the main Filesystem object, the Drive object, the Folder object, the File object, and the TextStream object.

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And here's a great FSO resource:

    Could I get some help working with files using FileSystemObject?
    http://www.aspfaq.com/show.asp?id=2039
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •