Jump to content

Autoit devs need to take a math class.......


Grimster
 Share

Recommended Posts

trancexx,

I get these values - Vista x32 if that makes any difference:

Drive             C:              M:

DriveSpaceTotal =  253 549 992 187   99 999 996 093
His correction  =  265 866 436 608  104 857 555 404
Windows      =  265 866 436 608  104 857 595 404

The first 2 values come from the OP's code, the Windows values are those given by selecting the drive in Explorer and looking at the Properties dialog. :)

M23

What are the units of numbers displayed in properties dialog?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

trancexx,

265,866,436,608 bytes    247 GB

M23

And I see the OP has still not amended the title. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

trancexx,

265,866,436,608 bytes   247 GB

M23

And I see the OP has still not amended the title. :)

But you said OP's results are correct (being what your properties say).

For your drives AutoIt will report:

ConsoleWrite("AutoIt says " & DriveSpaceTotal("C:") * 1024 * 1024 & " bytes" & @CRLF)
ConsoleWrite("AutoIt says " & DriveSpaceTotal("M:") * 1024 * 1024 & " bytes" & @CRLF)

And that should be exactly what properties box says.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

trancexx,

It does. :D

So if I understand correctly the OP was making the 1000/1024 error in his initial calculation of the returned MB value from DriveSpaceTotal and correctly calculating it for the "corrected" value. ;)

Or have I misunderstood again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Help file creates a confusion. More correct would be to say Returns the total disk space of a path in Mebibytes.

But then it would be "Is drive space storage space or memory space?"

All in all, DriveSpaceTotal should simply return bytes. Then there wouldn't be any confusion.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

Chimaera,

I think that is what I have been using for many years now if this thread is anything to go by! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Speaking of math classes... doesn't your "conversion" :

$HDspace = DriveSpaceTotal("c:")
$hdspace = $hdspace * 1000000
$hdspace = $hdspace/1024
$hdspace = $hdspace/1000000
$hdspace = $hdspace*1024*1024*1024
$hdspace = $hdspace/1000000

boil down to :

$hdspace = DriveSpaceTotal("c:") * 1.024 * 1.024

Just a basic KB=1000 to KB=1024 conversion... haven't been dealing with those for 30 years <cough>

Edit: Of course that formula only works for drives in the MB range. Dig your old 500KB drive out of the box in the basement, or break the TB threshhold, and it would report incorrectly. You'd need a function containing a loop to handle any value...

Global $BytesReported = DriveSpaceTotal("C:") * 1000000
Global $BytesActual = DriveSpaceAdjusted($BytesReported)
MsgBox(0,"","Btyes Reported: " & $BytesReported & @CRLF & "Btyes Actual:      " & $BytesActual)

Func DriveSpaceAdjusted($in)
  Local $out = $in
  $in /= 1000 ; no conversion for last 3 decimal places
  While $in > 1000
      $in /= 1000
      $out *= 1.024
  WEnd
  Return $out
EndFunc

Since, for me, Windows reports 640+ million bytes and 596MB, the 610+ million number returned by DriveSpaceTotal() seems of little use. So, I agree with your premise about the need for a change, but your delivery certainly isn't scoring you any points :)

Edited by Spiff59
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...