mIRC Homepage
Posted By: clutz1572 combo boxes - 02/09/04 06:06 PM
hello again :

i need some help with linking two combo boxes together, so to speak. i have two combos in my dialog one for nick and another for the nick hostmark. is there a way to sorta have them linked together, so when they write to a text file they will appear together as one unit when called? (don't know if i'm making sense but...). what i guess i'm trying to relay is that i need the two boxes to combine and be written into one file then displayed again in their own respective boxes???
Posted By: ATMA Re: combo boxes - 03/09/04 02:35 AM
write <file> $nick. $address($1,1)

$1 is the nickname then when u go to write it into the boxes $gettok it to devide it :P

eg:

$gettok$read(<file>, <line>), 1, $asc(.))
the above line will return you the nick name to get the address just change the 1 to a 2 and that will give the address

heres some sample code to aid you:
Code:
alias tie {
  write nickAdd.txt $1 $+ . $address($1, 1) 
  echo Wrote address
}
on *:somedialog:init:*: {
  var %a = 1
  while (%a &lt;= $lines(nickAdd.txt)) {
    did -a $dname &lt;id&gt; $gettok($read(nickAdd.txt, %a), 1, $asc(.))
    did -a $dname &lt;other id&gt; $gettok($read(nickAdd.txt, %a), 2, $asc(.))
  }
}


i think that might help you to some exstant :P
Posted By: Iori Re: combo boxes - 03/09/04 08:25 AM
Assuming both combos have the corresponding nick-host on the same lines.
To write the items to file using chr58 ":" as the seperator.
  • .fopen -no cc file.ext
    var %i = 1
    while $did(dname,id1,%i) {
    .fwrite cc $+($v1,:,$did(dname,id2,%i))
    inc %i
    }
    .fclose cc


To read them into the combos
  • .fopen cc file.ext
    while !$feof {
    if $fread(cc) {
    tokenize 58 $v1
    did -a dname id1 $1
    did -a dname id2 $2
    }
    }
    .fclose cc

Posted By: clutz1572 Re: combo boxes - 03/09/04 06:11 PM
Thanks for the replies ppl, but now i'm confused..

ok i'm doing my best to understand and follow the diff styles of code you guys have suggested... but this is where i'm getting confused:

i'm having trouble trying to link the actions to the corresponding action buttons

this is what i have :
Code:
 dialog anti-op {
  title "AwSuMovies :  Anti-Op"
  size -1 -1 290 154
  option dbu
  icon C:\MIRC\mIRC-multi.ico, 0
  button "OK", 1, 83 137 25 12, ok cancel
  combo 2, 9 43 60 50, size
  combo 3, 125 78 60 50, size
  check "Enable", 4, 14 126 28 10
  box "Active Channels", 5, 4 34 71 63
  box "Authorised Ops", 6, 121 61 160 83, group
  text "Hostmasks", 10, 217 70 28 8
  combo 9, 190 78 87 50, size
  check "Disable", 11, 14 139 28 10
  text "This option allows you to prevent any user(s) from accidentaly getting opped! ", 7, 92 14 183 8
  text "Input the nick and hostmask of your fellow ops", 8, 143 51 115 8
  text "Input the channel(s) you are opped in", 12, 7 16 69 13
  button "Add", 13, 10 101 22 11
  button "Remove", 14, 40 101 23 11
  text "Nicks", 15, 146 70 14 8
  button "Add", 16, 157 130 26 12
  button "Remove", 17, 203 130 25 12
}
on *:anti-op:init:*:{
  .fopen -no cc dat\amanti-op.txt
     var %i = 1
      while $did(dname,2,%i) {
     .fwrite cc $+($v1,:,$did(dname,3,%i))
      inc %i
   }
  }
  .fclose cc
on *:anti-op:edit:*:{
     if ($did == 16) { .fopen cc amanti-op.txt
       while !$feof {
         if $fread(cc) {
             tokenize 58 $v1
    did -a dname 2 $1
    did -a dname 3 $2
  }
}
.fclose cc
 


is that how it's supposed to be? if not, am i even close??
i haven't tried it yet but this is my best guess, atm .....

thanks for your help thus far and the on going help with this..
please be patient with me i'm still kinda new at this... and i'm trying to get it... blush



Posted By: Iori Re: combo boxes - 04/09/04 04:51 AM
Well, you appear to have the wrong ID for the combos. wink
You're writing the file on init, when you should be reading. laugh
One event reads from dat\amanti-op.txt and the other tries to write to amanti-op.txt
You used "dname" as the dialog name which should have been "anti-op" or "$dname" ($dname returns 'anti-op' in this case).
You also have an 'edit' event with "if $did == 16" when id16 is a button. :tongue:
on *:anti-op:init:*:{ <-should be-> on *:dialog:anti-op:init:*:{ (Same for the other dialog event)
Few other issues (bracket mismatches, /fclose command outside of event, etc)

What is the format of the hostmark you're entering? Full hostmark (e.g. nick!identd@host.com) or a wildmask (e.g. *!*@host.com / *!identd@*.host.com / etc).

Code:
on *:dialog:anti-op:sclick:*:{
  if $did == 16 {
    ; check if both combos have data
    if $did(3) &amp;&amp; $did(9) {
      ; add the data to the combo proper
      did -a $dname 3 $did(3)
      did -a $dname 9 $did(9)
      ; clear the edit field
      did -d $dname 3,9 0
    }
  }
  elseif $did == 17 {
    if $did(3).sel || $did(9).sel {
      did -d $dname 3,9 $v1
    }
  }
}
on *:dialog:anti-op:close:0:{
  if $did(3,1) {
    .fopen -no cc dat\amanti-op.txt
    var %i = 1
    while $did(3,%i) {
      .fwrite -n cc $+($v1,:,$did(9,%i))
      inc %i
    }
    .fclose cc
  } 
} 
on *:dialog:anti-op:init:0:{
  .fopen cc dat\amanti-op.txt
  if !$ferr {
    while !$feof {
      if $fread(cc) {
        tokenize 58 $v1
        did -a $dname 3 $1
        did -a $dname 9 $2
      }
    }
  }
  .fclose cc
}

NOTE: When called from a dialog event, $did() doesn't need the name field.
Posted By: clutz1572 Re: combo boxes - 04/09/04 05:58 AM
well, like i said i got confused....lol

Quote:
Well, you appear to have the wrong ID for the combos.
You're writing the file on init, when you should be reading.
One event reads from dat\amanti-op.txt and the other tries to write to amanti-op.txt


that was #1 thing i got confused about.. i thought that on init could be interpreted as like a on start command but for the script.. and thought that by looking at the code it would have to be written first to added to.. that was what i was going for there..(in case you were wondering) but i see now thats not the case..


Quote:
You used "dname" as the dialog name which should have been "anti-op" or "$dname" ($dname returns 'anti-op' in this case).
on *:anti-op:init:*:{ <-should be-> on *:dialog:anti-op:init:*:{ (Same for the other dialog event)
Few other issues (bracket mismatches, /fclose command outside of event, etc)


these lol were just mistakes, i just was in a hurry typeing it in cause i was running late for work.. :tongue:

Quote:
You also have an 'edit' event with "if $did == 16" when id16 is a button.

this one was under the assumtion that i thought i needed to use the button to add to the feilds.. but i kinda got the hint that this would be used with the combo box itself?..

but either way it was just a first time stab in the dark.. cool

for the hostmask i was thinking full nick!identd@host.com
Posted By: Iori Re: combo boxes - 04/09/04 07:05 AM
Quote:
for the hostmask i was thinking full nick!identd@host.com

In that case you only need to write that to file. smile You can grab the nick using $gettok() with 33 (the "!") as the delimiter.
Code:
on *:dialog:anti-op:close:0:{
  if $did(3,1) {
    savebuf -o $dname 9 dat\amanti-op.txt
    ; no need to save the "nick" combo because it's included in the hostmark.
  } 
} 
on *:dialog:anti-op:init:0:{
  loadbuf -o $dname 9 dat\amanti-op.txt
  var %i = 1
  while $did(9,%i) {
    did -a $dname 3 $gettok($v1,1,33)
    inc %i
  }
}
Simpler laugh
Posted By: clutz1572 Re: combo boxes - 06/09/04 09:30 PM
i'm not sure if i got it right, i've tried that code but it didn't appear to grab the nich from the mask and place it where it was supposed to be.. i liked the other one a little better *SHRUGS*
© mIRC Discussion Forums