mIRC Homepage
Posted By: _Marky_ listboxes - 25/12/02 08:56 AM
heres parts of a dialog i made:

Code:
  button "Add", 6, 220 30 23 12
  button "Remove", 7, 220 45 23 12
  edit "", 21, 122 20 95 10
  list 22, 122 32 95 34, size vsbar
}

on *:dialog:blaway:sclick:6: { did -a $dname 22 $did(21) | did -r $dname 21 }

on *:dialog:blaway:sclick:7: { did -d $dname 22 $did($dname,22).sel }


this is part of an away script
it adds reasons to the list box
How would i go about somehow saving the list, so that next time i open the dialog, its still there in the list box ?
Would i have to add and remove them from a txt file as i click the add and remove buttons, or is there a way to directly load up the list.

Posted By: Collective Re: listboxes - 25/12/02 09:28 AM
Code:
on *:dialog:blaway:init:0:{
  var %line = 1
  while ( $eval(% $+ blawayl $+ %line,2) != $null ) {
    did -a $dname 22 $eval(% $+ blawayl $+ %line,2)
    inc %line
  }
}
on *:dialog:blaway:close:0:{
  var %line = 1
  while ( $eval(% $+ blawayl $+ %line,2) != $null ) {
    unset $eval(% $+ blawayl $+ %line)
    inc %line
  }
  var %line = 1
  while ( $did(blaway,22,%line).text != $null ) {
    set %blawayl $+ %line $did($dname,22,%line).text
    inc %line
  }
}
Posted By: _Marky_ Re: listboxes - 25/12/02 10:30 AM
frown that didnt work
i made sure i had no other on *:dialog:blaway:init: or on *:dialog:blaway:close: commands
and it still didnt work
would there be any other way to go about it ?
Posted By: Collective Re: listboxes - 25/12/02 10:59 AM
I tested it on a fresh install of mIRC, worked fine. Some reasons why it wouldn't work is an outdated mIRC or not using "/dialog -m blaway blaway" to make the dialog.

The other ways of doing it would be putting while or goto loops in aliases and using the alias every time you opened/closed the dialog, but that is just a different way of writing the same thing.

No idea why it doesn't work for you, hopefully someone else can help confused

Here is the entire script I used:

Code:
dialog blaway {
  title "blaway"
  size -1 -1 223 145
  option dbu
  list 22, 5 25 100 100
}
on *:dialog:blaway:init:0:{
  var %line = 1
  while ( $eval(% $+ blawayl $+ %line,2) != $null ) {
    did -a $dname 22 $eval(% $+ blawayl $+ %line,2)
    inc %line
  }
}
on *:dialog:blaway:close:0:{
  var %line = 1
  while ( $eval(% $+ blawayl $+ %line,2) != $null ) {
    unset % $+ blawayl $+ %line
    inc %line
  }
  var %line = 1
  while ( $did(blaway,22,%line).text != $null ) {
    set %blawayl $+ %line $did($dname,22,%line).text
    inc %line
  }
}
Posted By: _Marky_ Re: listboxes - 25/12/02 01:49 PM
ok i wen through my hole script
i had an extra "}" b4 the script start
so it was stuffing it up
but now
if i remove a reason form the list box
the next time i open it
its still there confused
Posted By: Collective Re: listboxes - 25/12/02 01:51 PM
Dunno why that is, it shouldn't happen because all variables are unset and then set again when you close it. Works for me, very odd, and annoying,..
Posted By: _Marky_ Re: listboxes - 25/12/02 02:03 PM
im using 6.03 so i dunno...
ill fiddle around with it

thanks a bunch mate
Posted By: Nimue Re: listboxes - 25/12/02 09:11 PM
Code:
on *:dialog:blaway:init:*:{
  if ($exists(blawaybuf.txt)) loadbuf -o $dname 22 blawaybuf.txt
}
on *:dialog:blaway:close:*:{
  savebuf -o $dname 22 blawaybuf.txt
}
Posted By: _Marky_ Re: listboxes - 26/12/02 03:59 AM
that works perfectly grin
thanks
Posted By: NaquadaServ Re: listboxes - 26/12/02 03:17 PM
Besides using loadbuf, also check out /didtok and $didtok
© mIRC Discussion Forums