Diana (Cda) Posted August 15, 2008 Share Posted August 15, 2008 (edited) Hi. When I run this script:$var = DriveSpaceFree($USB_FlashDriveLtr) MsgBox(4096, "Free space on " & $USB_FlashDriveLtr, $var & " MB") ; no rounding at allI get a rounded up value of 996 MB since the rounding is going to closest number which this time happens to be a higher value. This isn't ideal in this case. It would be better that the return err on the side of caution and report back the closest smaller number. However, I couldn't find anything about rounding _down_. Is it possible to? Thx. Edited August 19, 2008 by Diana (Cda) Link to comment Share on other sites More sharing options...
Andreik Posted August 15, 2008 Share Posted August 15, 2008 Hi. When I run this script:$var = DriveSpaceFree($USB_FlashDriveLtr) MsgBox(4096, "Free space on " & $USB_FlashDriveLtr, $var & " MB") ; no rounding at allI get a rounded up value of 996 MB since the rounding is going to closest number which this time happens to be a higher value. This isn't ideal in this case. It would be better that the return err on the side of caution and report back the closest smaller number. However, I couldn't find anything about rounding _down_. Is it possible to? Thx. Use Floor function. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
jokke Posted August 15, 2008 Share Posted August 15, 2008 (edited) Abit early on the morning here but i think you could just cut away everything after "." something like this: $str = "995.9296875" $restult = StringLeft($str,StringInStr($str,".")-1) ConsoleWrite( $restult & @CRLF) Or offcource use the floor Edited August 15, 2008 by jokke UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt. Link to comment Share on other sites More sharing options...
Diana (Cda) Posted August 19, 2008 Author Share Posted August 19, 2008 (edited) Well, this works really well now. Thanks everyone for the tips. I finally figured out how to use this "floor" business <g>, which makes the reporting easier to understand. I use my own personal UDF now all the time (the one called "partition letters") where I just make one edit when I get to a new computer and it assigns a new letter to my USB flash drive. Computers are locked up at work now so easier to have the one reference that all USB flash drive scripts point to. In any case, now it's easy to keep track of how much free space there is on the stick with this, which is a simple script. I'll probably fine-tune in the future as I learn more:; ; AutoIt 3x ; #include <_PartitionLetters.au3> ; this replaces drive letters #include<_WEReplacement.au3> ; references a Windows Explorer replacement program AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid! #NoTrayIcon ; AutoIt's icon doesn't show in systray TraySetIcon(@ScriptDir & "\USB flash drive, disk space free.ico") ;------ Change target drive(s) to scan here, only: ----------------------- $DriveToScanForFreeSpace = $Work_USB_DriveLtr ;------------------------------------------------------------------------- $var1 = DriveSpaceFree($DriveToScanForFreeSpace) $var2 = DriveSpaceFree($DriveToScanForFreeSpace) $FreeSpace = $var1 $FreeSpaceRoundedDown = Floor($var2) MsgBox(64,"Free space on the ''" & $DriveToScanForFreeSpace & "\'' UFD drive ... ","The free space on the ''" & $DriveToScanForFreeSpace & "'' UFD drive is: " & @CRLF & _ "----------------------------------------------- " & @CRLF & @CRLF & _ $FreeSpace & " MB, exactly" & @CRLF & @CRLF & _ "or," & @CRLF & @CRLF & _ $FreeSpaceRoundedDown & " MB, rounded down.") Cheers. Edited August 19, 2008 by Diana (Cda) Link to comment Share on other sites More sharing options...
Diana (Cda) Posted August 19, 2008 Author Share Posted August 19, 2008 (edited) Oh, thought I should add, when I ran this just now, this is the type of output I get: --------------------------- Free space on the ''F:\'' UFD drive ... --------------------------- The free space on the ''F:'' UFD drive is: ----------------------------------------------- 986.29296875 MB, exactly or, 986 MB, rounded down. --------------------------- OK --------------------------- Edited August 19, 2008 by Diana (Cda) Link to comment Share on other sites More sharing options...
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