Jump to content

problem with fitting size to file in a list


tamir
 Share

Recommended Posts

ok i have 2 lists: 1 with files and 1 with their sizes.

i update the lists with a function, but when i do that the sizes mixing up in the order.

for examplei have 3 files |file name(size)|:

abc.txt(3485)

def.exe(8325)

ghi.au3(1209)

and the list order them like this:

name--------size

abc.txt-------1209

def.exe------3485

ghi.au3------8325

the function is this:

Func _FilesAddToList($par, $type)
   If $type == "" Then $type = "*.???"
   
  $scan = FileFindFirstFile(Eval("dir_" & $par) & "\" & $type)
   
   $list = ""
   $fsize = ""
   While $scan <> - 1
      $file = FileFindNextFile($scan)
      If @error Then
         FileClose($scan)
         ExitLoop
      EndIf
      
      If NOT ($file == "." Or $file == "..") Then
         $list = $list & "|" & $file
         $fsize = $fsize & "|" & FileGetSize($file)
      EndIf
   WEnd
   
   GUICtrlSetData(Eval("list_" & $par), $list)
   GUICtrlSetData(Eval("list_" & $par & "_size"), $fsize)
EndFunc

so whats the problem?

and btw, if i want to change bytes to Mb, what number to divide with?

Link to comment
Share on other sites

not sure how to help with first bit :D, but to divide in to MB use this

/ 1024 / 1024

if u want to divide in gig,

/ 1024 / 1024 / 1024

etc. This returns the size with like 20 decimal places but so use

Round (exp[b][/b]ression , decimalplaces)

to set a decimal place, i found 2 dp is nice :idiot:

Edited by burrup

qq

Link to comment
Share on other sites

  • Developers

ok i have 2 lists: 1 with files and 1 with their sizes.

so whats the problem?

and btw, if i want to change bytes to Mb, what number to divide with?

<{POST_SNAPBACK}>

The issue is that the listboxes will sort their values so mix up the sequence.

Its probably better to use 1 listbox with mutiple columns to keep name and size together...

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...