Guest fizbang Posted September 8, 2004 Posted September 8, 2004 I have a bunch of files with sequentially numbered extensions. I need a function that will return the file with the highest extention, '13' in the case below. The problem is, the function returns 9 as the highest. What's wrong? test.10 test.12 test.9 test.13 test.8 test.7 Func LastFile($ext) $search = FileFindFirstFile("*." & $ext) ; Check if the search was successful If $search = -1 Then return "" EndIf dim $test, $file While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $test = $file WEnd FileClose($search) return $test EndFunc Also if I do $x = "9" $y = "10" if $x > $y then $z = "yes" endif $z will always be yes. Is there a way to force them to be numbers?
Billy Posted September 10, 2004 Posted September 10, 2004 This works for me:=======================================Dim $search, $fileDim $ThisExt, $HighExt$search = FileFindFirstFile("*.*")If $search = -1 Then ExitWhile 1 $file = FileFindNextFile($search) If @error Then ExitLoop $NameParts=StringSplit($File, ".") $ThisExt = Number($NameParts[ubound($NameParts)-1]) If $ThisExt > $HighExt Then $HighExt = $ThisExt $HighFile = $File EndIf WendFileClose($search)MsgBox(0,"Results", "Max extension file = " & $HighFile)=======================================The poop being that ASCII "13" comes before ASCII "9". I grab the extension, convert it to a number THEN do my comparisons.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now