DigDeep Posted May 19, 2017 Posted May 19, 2017 Not sure what am I doing wrong here... If less than 50GB then the 1st one. If less than 1023MB then 2nd one, else if more than 50GB then 3rd one. Can someone please fix this? $FreeSpace = DriveSpaceFree(@HomeDrive & "\") If _ShowBytes($FreeSpace) < 50 & ' GB' Then MsgBox(0, '', 'Less Than 50 GB') ElseIf _ShowBytes($FreeSpace) < 1023 & ' MB' Then MsgBox(0, '', 'Less Than 1023 MB') Else ; More than 50 GB MsgBox(0, "", _ShowBytes($FreeSpace)) EndIf Func _ShowBytes($bytes) Local $x, $bytes_suffix[2] = [" MB", " GB"] While $bytes > 1023 $x += 1 $bytes /= 1024 WEnd Return Round($bytes) & $bytes_suffix[$x] EndFunc ;==>_ShowBytes
benners Posted May 19, 2017 Posted May 19, 2017 Could try this $FreeSpace = DriveSpaceFree(@HomeDrive & "\") If Round($FreeSpace) < 1023 Then MsgBox(0, '', 'Less than 1023 MB') ElseIf Round($FreeSpace / (1024 ^ 1)) < 50 Then MsgBox(0, '', 'Less Than 50 GB') Else MsgBox(0, "", Round($FreeSpace / (1024 ^ 1)) & ' GB') EndIf
Moderators JLogan3o13 Posted May 20, 2017 Moderators Posted May 20, 2017 @benners just curious why you feel the need to do your division and then tack on ^ 1? Completely unnecessary. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
benners Posted May 20, 2017 Posted May 20, 2017 Yep you're right. It was from some old code I had that that went MB GB TB etc, so the 1024 was rooted accordingly so I just copied and pasted.
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