Brad Perkins wrote:
> This is admittedly not a difficult problem to solve but I was curious
> is anyone has and might share code that given a file size in bytes
> would return a string showing the size in appropriate Kb, Mb or Gb
> designation?
>
> Thanks
>
> Brad Perkins
I found some PHP code and adapted it.
method "print_file_size" ($inBytes;$round = 2)
c_text($outSizeTxt)
$outSizeTxt := ""
If (( $inBytes > 0 ) & ( $inBytes < (1024^4) ))
array text ($sizes;0)
set array($sizes; " B"; " kB"; " MB"; " GB") `could be
extended for TB, PB, EB, ...
for ($i; 1 ; size of array($sizes))
if($inBytes < (1024^$i))
$outSizeTxt :=
string(round($inbytes/(1024^($i-1));$round)) + $sizes{$i}
break
end if
end for
end if
return ($outSizeTxt)
end method
-- Brad
_______________________________________________
Active4D-dev mailing list
Active4D-dev@...
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-devArchives:
http://mailman.aparajitaworld.com/archive/active4d-dev/