Jump to content

_arraySort fails ?


mozart90
 Share

Recommended Posts

Hi,

I want to write filenames and the filedates in an 2-dimentional array then sort them to find out the newest files.

but the sort functions fails? why?

or do you have any other suggestions for realizing?

I need to know the newest file in several directories.

#include <Array.au3>

finddoc ("C:\tty\")



func finddoc($path)
dim $filearray[1][2]
$n=0
$search = FileFindFirstFile($path & "*.doc")  
; Check if the search was successful

If $search = -1 Then
    ;MsgBox(0, "Error", "No files/directories matched the search pattern")
    return 
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    
    $docdate= filegettime($path & $file,1,1) 
    if @error=1 then msgbox(0,"","Error get time") 
    
    $filearray[$n][0] = $docdate
    $filearray[$n][1] = $file

    redim $filearray[ubound($filearray,1)+1][2]
    $n=$n+1
WEnd

; Close the search handle
FileClose($search)

_ArraySort($filearray,0,1)

endfunc

greetings mozart90

Edited by mozart90
Link to comment
Share on other sites

....

but the sort functions fails? why?

...

....
dim $filearray[1][2]
....
_ArraySort($filearray,0,1)
....

$i_Dim Optional: Number of occurences in the second dimension

eg $A[100] = 0, $A[100][2] = 2, $A[100][5] = 5

Optional here means that if you do not have a second dimension you do not need to supply it.

But when you do you must fill it in. After getting the error-message (you did not mention :P ) a quick test revealed that. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...