Jump to content
Sign in to follow this  
tamir

problem with fitting size to file in a list

Recommended Posts

tamir

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?

Share this post


Link to post
Share on other sites
buzz44

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.