Use the "$Var = 1.0 * GetFileSize()" when you first reference the function, not later when you use the value. By immediately casting to a float, Kix will retain it as a float.

Also, your code is fairly ineffecient.. your Select/Case calls the "DateCalc(@date,substr(getfiletime($File),1,10))" over and over until a match is found. Try something like
 Code:
$Age = DateCalc(@date,substr(getfiletime($File),1,10))
Select
 Case $Age <= 365
  stuff..
 Case $Age >365 And $Age <= 730
  stuff..
EndSelect
Also - this method doesn't account for leap years, which may or may not be important. The TimeDiff() UDF can return the age in years as a decimal value, so if a file is 547 days old, the value returned would be "1.5" You could then do something like
 Code:
For Each $File in $Files
  ; TimeDiff - calculate time between two date/time values
  ; Arg 1: Start Date/Time
  ; Arg 2: End Date - use "now" for calculating age to the minute, "today" to calculate on today's date only
  ; Arg 3: 1 char value to return time in Minutes, Hours, Days, or Years
  ; Arg 4: (not used here) Calculate difference to ms instead of seconds 
  $Years = TimeDiff(getfiletime($File),1,10), 'today', 'y') 
  SELECT
   ; work in reverse age order
   Case $Years > 5   ; OLD!
    REDIM PRESERVE $aOld[1+UBOUND($aOld)]
    $aOld[UBOUND($aOld)] = $File
   Case $Years >= 4   ; 
    REDIM PRESERVE $a4Years[1+UBOUND($a4Years)]
    $a4Years[UBOUND($a4Years)] = $File
   Case $Years >= 3
    REDIM PRESERVE $a3Years[1+UBOUND($a3Years)]
    $a3Years[UBOUND($a3Years)] = $File
   Case $Years >= 2
    REDIM PRESERVE $a2Years[1+UBOUND($a2Years)]
    $a2Years[UBOUND($a2Years)] = $File
   Case $Years >= 1
    REDIM PRESERVE $a1Year[1+UBOUND($a1Year)]
    $a1Year[UBOUND($a1Year)] = $File
   Case 1
    REDIM PRESERVE $aRecent[1+UBOUND($aRecent)]
    $aRecent[UBOUND($aRecent)] = $File
  EndSelect
Next
By working "backwards", you don't have to perform range calculations on each Case. You can just compare the years as being greater or equal to some value. For example, if a file is 5.3 years old, it trips the first Case and the rest are ignored.. if a file is 2.3 years old, the >=5, >=4 and >=3 case comparisons fail, and the >=2 Case triggers and the remaining are ignored.

TimeDiff() is also leap-year aware, eliminating any chance for error. The latest version of TimeDiff is on my web site's Resources/Kix UDF Library page. TimeConvert() is also available to convert between cTime and string date/time values. Feed it a date/time and you get a cTime value. Feed it a cTime value, you get a Date/time string. Supports negative cTime values and a definable epoch so you can perform calculations from BC to the present. Note that it does not handle the calendar change of September 1752. If your dates pass over that range, you will need to subtract the missing calendar days from your result. It's unlikely that this will ever impact your file age logic. \:D

Glenn


Edited by Glenn Barnas (2012-11-10 02:50 PM)
Edit Reason: add reference link
_________________________
Actually I am a Rocket Scientist! \:D