mIRC Home    About    Download    Register    News    Help

Print Thread
deleting partial variables #14366 06/03/03 10:47 PM
Joined: Dec 2002
Posts: 1,527
_
_D3m0n_ Offline OP
Hoopy frood
OP Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
Code:
on *:DIALOG:dnc:sclick:25:{ 
  //write nicks.ini $calc($did(dnc,28).sel -1) $did(23).text
  set %dnccolor. $+ $did(23).text $calc($did(dnc,28).sel -1)
  set %specialnicks %specialnicks $did(23).text
  did -a dnc 21 $calc($did(dnc,28).sel -1) $did(23).text
  did -r dnc 23
}
on *:DIALOG:dnc:sclick:26:{ 
  //write -dl $+ $did(21).sel nicks.ini
  unset dnccolor. $+ $read(nicks.ini, $did(21).sel)
  did -d dnc 21 $did(21).sel
}


ok i know that by looking at it it doesnt show much .....
but what im trying to do is add a list of nicks to a variable separated by a space ..... then look for a nick in that variable using isin %specialnicks ..... to add a cline command .....
i can add the nicks np and set its correct color variable like

%dnccolor.nickname 2

and the specialnick variable like

%specialnicks nick1 nick2 nick3 nick4

but what im trying to do is also have it delete nicks and color variables from there ... and its klinda giving a bit of trouble ..... im able to delete them from the ini file to store the nicks for the dialog but im having a bit of trouble say deleting just one nick from that special friends list ...... i dont know how id go about just removing one word in a variable and then resetting the variable?? any help would be appreciated very much .....


D3m0nnet.com
Re: deleting partial variables #14367 06/03/03 11:16 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Tokens would be the natural choice for achieving everything you want here - $addtok(), $istok(), and $remtok(), would make the whole thing a lot simpler.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: deleting partial variables #14368 07/03/03 02:14 AM
Joined: Dec 2002
Posts: 1,527
_
_D3m0n_ Offline OP
Hoopy frood
OP Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
kewl ty starbucks ...... works exactly what i neded it too after i read up on finding things

for anyone interested this is the new working code

Code:
on *:DIALOG:cnl:sclick:25:{ 
  //write nicks.ini $did(23).text $calc($did(cnl,28).sel -1)
  set %cnlcolor. $+ $did(23).text $calc($did(cnl,28).sel -1)
  if $did(23).text isin %specialnicks { echo -a added to list }
  else { set %specialnicks %specialnicks $did(23).text }
  did -a cnl 21 $did(23).text $calc($did(cnl,28).sel -1) 
  did -r cnl 23
  ;  did -r cnl 31
}
on *:DIALOG:cnl:sclick:26:{ 
  //write -dl $+ $did(21).sel nicks.ini
  set %temptok $1($did(21).seltext) 
  unset cnlcolor. $+ $gettok(%temptok,1,32)
  set %specialnicks $deltok(%specialnicks,$findtok(%specialnicks,$gettok(%temptok,1,32),32),32)
  did -d cnl 21 $did(21).sel
  unset %temptok
}


again ty for the heads up there starbuckswasnt sure how to get that figured out


D3m0nnet.com
Re: deleting partial variables #14369 07/03/03 05:34 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
You don't need // before write. It's in a script; everything that starts a line in a script must be a command of some sort (excepting ; for a comment line or } for a block close).


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: deleting partial variables #14370 07/03/03 05:59 AM
Joined: Dec 2002
Posts: 1,527
_
_D3m0n_ Offline OP
Hoopy frood
OP Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
ty hammer ...... i keep forgetting that one ......
now that ivwe finally gotten this far ..... how can u remove text in a listbox if ur tryin to enter the same name in it

my listbox contains both a name and a number after it but say someone tries to overwrite it without deleteing ,,, ive adding some code to fix that problem inside the nicks ini and cvariables im storing the info in ... but once u add it i am not sure how to remove the extra nick number combo in the list box without clicking delete cause clickign that after uve already added a new one would then erase the newly aded info in variables and in the nics ini


say ive got this for instance

Nick1 4 nick1
nick2 2
nick3 7
nick4 10 colortogive typed nick: 12
nick5 13
nick6 15 ADD typed DELETE Selected

--------------------------------------------------------------------

ok now click add right now when i have nick 1 and 12 selected in the color adds nick1 12 to the bottom of the list ..... it changes all the variables on nick1 and once u reopen the dialog its not there cause its no longer in the ini it reads from ..... but i want to make it delete that line from it right when i click add of a previously added nick ..... im having trouble figureing out which would be the easiest ...... and workable way to get it to actuaslly find the line nuber of the text line i want removed ....... anyhow any help on this lil nuisance im having would be appreciated


D3m0nnet.com
Re: deleting partial variables #14371 07/03/03 11:54 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
While I didn't really understand exactly what you were saying, I decided to take a stab at it anyway. Is this what you had in mind? (Understand the code, don't just try to copy/paste - then you'll be able to figure out what's wrong with your own current code.)
Code:

;  Minimal dialog example
;  
;  Listbox ID = 21
;  Nick editbox ID = 23
;  Add button ID = 25
;  Delete buton ID = 26
;  Color combo ID = 28  
;
dialog cnl {
  option dbu
  title "Colorful nicks"
  size -1 -1 115 67
  list             21,   5   5  50  50, sort
  edit "",         23,  60   5  50  10
  combo            28,  60  20  50  80, drop
  button "Add",    25,  25  50  30  13  
  button "Delete", 26,  60  50  30  13
}
 
alias cnl dialog -m cnl cnl                                         | ; [ Start up the dialog interface         ]
 
on *:DIALOG:cnl:init:0:{                                            | ; [ Initialize the dialog                 ]
                                                                    | ; 
  did -a $dname 28 00 - White                                       | ; Add all the colors
  did -a $dname 28 01 - Black                                       | ; 
  did -a $dname 28 02 - DkBlue                                      | ; 
  did -a $dname 28 03 - DkGreen                                     | ; 
  did -a $dname 28 04 - Red                                         | ; 
  did -a $dname 28 05 - Brown                                       | ; 
  did -a $dname 28 06 - DkPurple                                    | ; 
  did -a $dname 28 07 - Orange                                      | ; 
  did -a $dname 28 08 - Yellow                                      | ; 
  did -a $dname 28 09 - LtGreen                                     | ; 
  did -a $dname 28 10 - Teal                                        | ; 
  did -a $dname 28 11 - Aqua                                        | ; 
  did -a $dname 28 12 - LtBlue                                      | ; 
  did -a $dname 28 13 - LtPurple                                    | ; 
  did -a $dname 28 14 - DkGrey                                      | ; 
  did -a $dname 28 15 - LtGrey                                      | ; 
                                                                    | ; 
  did -c $dname 28 2                                                | ; Select Black
  did -b $dname 25,26                                               | ; Disable both buttons
                                                                    | ; 
  if $lines(nicks.ini) == 0 return                                  | ; If there are no nicks on file, stop
                                                                    | ; 
  var %i = 1                                                        | ; Loop index
  while $ini(nicks.ini, colors, %i) != $null {                      | ; While there are more nicks
    did -a $dname 21 $ifmatch $readini(nicks.ini, colors, $ifmatch) | ;   Add each nick and color value
    inc %i                                                          | ;   Get next nick
  }                                                                 | ; 
}
 
on *:DIALOG:cnl:sclick:25:{                                         | ; [ Adding or Overwriting                 ]
                                                                    | ; 
  var %nick = $did(23)                                              | ; Nick
  var %color = $calc($did(28) - 1)                                  | ; Color
                                                                    | ; 
  writeini nicks.ini colors %nick %color                            | ; Save it disk
  set $+(%,cnlcolor.,%nick) %color                                  | ; Save it to variables
  set %specialnicks $addtok(%specialnicks, %nick, 32)               | ; 
                                                                    | ; 
  if $did(21, 0).sel == 0 did -a $dname 21 %nick %color             | ; If it's new, add it
  else did -o $dname 21 $did(21, 1).sel %nick %color                | ; Otherwise, overwrite it
                                                                    | ; 
  did -r $dname 23                                                  | ; Clear the nick editbox
  did -b $dname 25,26                                               | ; Disable the buttons
}
 
on *:DIALOG:cnl:sclick:26:{                                         | ; [ Deleting an entry ]
                                                                    | ; 
  if $did(21, 0).sel == 0 return                                    | ; If nothing is selected, stop
                                                                    | ; 
  var %nick = $gettok($did(21).seltext, 1, 32)                      | ; Get the nick to remove
                                                                    | ; 
  unset $+(%,cnlcolor.,%nick)                                       | ; Unset the variables
  set %specialnicks $remtok(%specialnicks, %nick, 1, 32)            | ; 
                                                                    | ; 
  remini nicks.ini colors %nick                                     | ; Remove from disk
                                                                    | ;  
  did -d $dname 21 $did(21).sel                                     | ; Delete the listbox line
  did -r $dname 23                                                  | ; Clear the nick editbox
  did -b $dname 25,26                                               | ; Disable the buttons
}
 
on *:DIALOG:cnl:edit:23: Enable.Add-Overwrite                       | ; [ Check for status changes on nick edit ]
 
on *:DIALOG:cnl:sclick:28: Enable.Add-Overwrite                     | ; [ Or color change                       ]
 
on *:DIALOG:cnl:sclick:21:{                                         | ; [ Selecting a listbox line              ]
                                                                    | ; 
  did -ra $dname 23 $gettok($did(21, 1).seltext, 1, 32)             | ; Insert old nick into nick editbox
  did -c $dname 28 $calc($gettok($did(21, 1).seltext, 2, 32) + 1)   | ; Select old color
                                                                    | ; 
  Enable.Add-Overwrite                                              | ; Check for status changes
}
 
alias -l Enable.Add-Overwrite {                                     | ; [ Status Changes                        ]
                                                                    | ; 
  var %newnick = $did(23)                                           | ; Nick from editbox
  var %newcolor = $calc($did(28).sel - 1)                           | ; Color from combo
                                                                    | ; 
  if $didwm(21, %newnick *) > 0 {                                   | ; If we're back to using the same nick
    did -c $dname 21 $ifmatch                                       | ;   select it in the listbox
    did -ra $dname 25 Overwrite                                     | ;   rename to Overwrite
    if $gettok(%seltext, 2, 32) == %newcolor {                      | ;   If the color is the same too
      did -b $dname 25                                              | ;     disable Overwrite
    }                                                               | ; 
    else {                                                          | ;   Otherwise
      did -e $dname 25                                              | ;     enable Overwrite
    }                                                               | ; 
  }                                                                 | ; 
                                                                    | ; 
  var %seltext = $did(21, 1).seltext                                | ; Get the old listbox nick and color
  var %oldnick = $gettok(%seltext, 1, 32)                           | ; 
  var %oldcolor = $gettok(%seltext, 2, 32)                          | ; 
                                                                    | ; 
  if %oldnick %oldcolor == %newnick %newcolor {                     | ; If the lines are the same
    did -b $dname 25                                                | ;   disable Overwrite
    did -e $dname 26                                                | ;   enable Delete
  }                                                                 | ; 
  elseif %oldnick != $null && %oldnick != %newnick {                | ; If the new nick is different
    did -u $dname 21                                                | ;   unselect it
    did -ra $dname 25 Add                                           | ;   rename Overwrite to Add
    if %newnick != $null {                                          | ;   If there's a new nick
      did -e $dname 25                                              | ;     enable Add
    }                                                               | ; 
    else {                                                          | ;   Otherwise
      did -b $dname 25                                              | ;     disable Add
    }                                                               | ; 
    did -b $dname 26                                                | ;   and disable Delete (no nick yet added)
  }                                                                 | ; 
  elseif %oldnick == $null {                                        | ; If there's no selected nick
    did -are $dname 25 Add                                          | ;   rename Overwrite to Add and enable it
    did -b $dname 26                                                | ;   disable Delete
  }
}


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: deleting partial variables #14372 09/03/03 08:39 AM
Joined: Dec 2002
Posts: 1,527
_
_D3m0n_ Offline OP
Hoopy frood
OP Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
again hammer i thank you for showing me these things ..... that alias u made into your example is exactly the type of thing i was asking how to do, ty so much for that ..... its taken me acouple days to finally get it going the way i wanted to and without the help of the ppl in these forums and especially you id still be racking my head on the desk trying to figure out how come i cant get it to delete ...... again ty hammer


D3m0nnet.com
Re: deleting partial variables #14373 09/03/03 09:30 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
You're quite welcome. I'm glad you learned from my example of one way to do that sort of thing.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: deleting partial variables #14374 09/03/03 12:08 PM
Joined: Dec 2002
Posts: 2,984
Watchdog Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,984
Looks good, I'm just glad I didn't have to type it all. grin


Induced IRC
irc.induced.net