mIRC Homepage
Posted By: onesikgypo Displaying List Of Files In Dialog - 21/02/06 11:32 AM
hi if i had a simple
on *:DIALOG:name:*:*:{
if ($devent == init) {
...code here (say the list has the id 6)

and the files that would need to be listed are "$getdir"
Posted By: MikeChat Re: Displaying List Of Files In Dialog - 21/02/06 08:01 PM
sample
Code:
dialog list {
  title ""
  size -1 -1 100 100
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
}
on *:dialog:list:init:0:{
  var %null = $findfile($getdir,*,0,did -a list 6 $1-)
  did -z list 6
}
Posted By: onesikgypo Re: Displaying List Of Files In Dialog - 22/02/06 08:55 AM
is it poss u could provide the coding for

if ($devent == dclick)

if its a folder, to change folders, and .. to go back etc.?
Posted By: MikeChat Re: Displaying List Of Files In Dialog - 22/02/06 06:33 PM
you are thinking along the lines of @windows?
I have shown two ways.
1) Added a button, buttons are more understandable
if you plan to share your script
2) I did include double clicking inside the listbox. A cleaner look,
but others might be confused by "hidden" controls.
sample
Code:
dialog list {
  title ""
  size -1 -1 100 110
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
  button "Change Folder", 901, 25 95 50 10
}
on *:dialog:list:init:0:{
  var %null = $findfile($getdir,*,0,did -a list 6 $1-)
  did -z list 6
}
on *:dialog:list:sclick:901:{
  if (!%filesource) { set %filesource $getdir }
  set %filesource $sdir(%filesource)
  did -r list 6
  var %null = $findfile(%filesource,*,0,did -a list 6 $1-)
  did -z list 6
}
on *:dialog:list:dclick:6:{
  if (!%filesource) { set %filesource $getdir }
  set %filesource $sdir(%filesource)
  did -r list 6
  var %null = $findfile(%filesource,*,0,did -a list 6 $1-)
  did -z list 6
}
Posted By: onesikgypo Re: Displaying List Of Files In Dialog - 23/02/06 05:36 AM
umm not quite what i was thinking but it does the job smile

lol last thing i was hoping for is file sizes in both bytes and mb to be shown (either in a corresponding listbox/in the original listbox/ even a disabled editbox that shows the size of the selected one)
Posted By: SladeKraven Re: Displaying List Of Files In Dialog - 23/02/06 06:11 AM
Code:
dialog list {
  title ""
  size -1 -1 100 130
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
  list 7, 15 94 70 20
  button "Change Folder", 901, 25 117 50 10
}

on *:dialog:list:*:*:{
  if ($devent == init) {
    var %null = $findfile($getdir,*,0,did -a list 6 $1-)
    did -z list 6
  }
  if ($devent == sclick) {
    if ($did == 901) {
      if (!%filesource) { set %filesource $getdir }
      set %filesource $sdir(%filesource)
      did -r list 6
      var %null = $findfile(%filesource,*,0,did -a list 6 $1-)
      did -z list 6
    }
    if ($did == 6) {
      did -r $dname 7
      did -a $dname 7 $bytes($file($did($dname,6).seltext),b) bytes
      did -a $dname 7 $bytes($file($did($dname,6).seltext),m) mb
    }
  }
  if ($devent == dclick) {
    if (!%filesource) { set %filesource $getdir }
    set %filesource $sdir(%filesource)
    did -r list 6
    var %null = $findfile(%filesource,*,0,did -a list 6 $1-)
    did -z list 6
  }
}


-Andy
Posted By: onesikgypo Re: Displaying List Of Files In Dialog - 23/02/06 07:36 AM
i did just a few modifications to remove most of the path, note the $remove's

Code:
dialog list {
  title ""
  size -1 -1 100 130
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
  list 7, 15 94 70 20
  button "Change Folder", 901, 25 117 50 10
}

on *:dialog:list:*:*:{
  if ($devent == init) {
    set %filesource $getdir
    var %null = $findfile($getdir,*,0,did -a list 6 $remove($1-,$getdir))
    did -z list 6
  }
  if ($devent == sclick) {
    if ($did == 901) {
      if (!%filesource) { set %filesource $getdir }
      set %filesource $sdir(%filesource)
      did -r list 6
      var %null = $findfile(%filesource,*,0,did -a list 6 $remove($1-,%filesource))
      did -z list 6
    }
    if ($did == 6) {
      did -r $dname 7
      did -a $dname 7 $bytes($file($did($dname,6).seltext),b) bytes
      did -a $dname 7 $bytes($file($did($dname,6).seltext),m) mb
    }
  }
  if ($devent == dclick) {
    if (!%filesource) { set %filesource $getdir }
    set %filesource $sdir(%filesource)
    did -r list 6
    var %null = $findfile(%filesource,*,0,did -a list 6 $remove($1-,%filesource))
    did -z list 6
  }
}


Problem im finding is in $getdir (weather by initialisation or by selecting it) it wont show the file sizes now that i have done $remove($1-,$getdir)
Posted By: SladeKraven Re: Displaying List Of Files In Dialog - 23/02/06 07:41 AM
Code:
dialog list {
  title ""
  size -1 -1 100 130
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
  list 7, 15 94 70 20
  button "Change Folder", 901, 25 117 50 10
}

on *:dialog:list:*:*:{
  if ($devent == init) {
    set %filesource $getdir
    var %null = $findfile($getdir,*,0,did -a list 6 $remove($1-,$getdir))
    did -z list 6
  }
  if ($devent == sclick) {
    if ($did == 901) {
      if (!%filesource) { set %filesource $getdir }
      set %filesource $sdir(%filesource)
      did -r list 6
      var %null = $findfile(%filesource,*,0,did -a list 6 $remove($1-,%filesource))
      did -z list 6
    }
    if ($did == 6) {
      did -r $dname 7
      did -a $dname 7 $bytes($file([color:blue]$+(%filesource,$did($dname,6).seltext)[/color]),b) bytes
      did -a $dname 7 $bytes($file([color:blue]$+(%filesource,$did($dname,6).seltext)[/color]),m) mb
    }
  }
  if ($devent == dclick) {
    if (!%filesource) { set %filesource $getdir }
    set %filesource $sdir(%filesource)
    did -r list 6
    var %null = $findfile(%filesource,*,0,did -a list 6 $remove($1-,%filesource))
    did -z list 6
  }
}


-Andy
Posted By: MikeChat Re: Displaying List Of Files In Dialog - 23/02/06 07:58 PM
Quote:
i did just a few modifications to remove most of the path, note the $remove's


this is my solution to having the files listed, no path showing, with the bytes and megabyte sizes listed after the filename.
note any files under 5k will show as 0mb. (megabyte rounding rule im guessing is over 5k is 0.01mb)
Code:
dialog list {
  title ""
  size -1 -1 100 110
  option dbu
  list 6, 5 5 90 90, sort hsbar vsbar
  button "Change Folder", 901, 25 95 50 10
}
on *:dialog:list:init:0:{
  var %null = $findfile($getdir,*,0,listfileinfo $1-)
  did -z list 6
}
on *:dialog:list:sclick:901:{
  if (!%filesource) { set %filesource $getdir }
  set %filesource $sdir(%filesource)
  did -r list 6
  var %null = $findfile(%filesource,*,0,listfileinfo $1-)
  did -z list 6
}
alias listfileinfo {
  var %listfile = $1-
  var %listsize = $bytes($file(%listfile),b).suf $bytes($file(%listfile),m).suf
  did -a list 6 $nopath(%listfile) %listsize
}
© mIRC Discussion Forums