All pastes #175574 Raw Edit

Mine

public text v1 · immutable
·published 2006-09-18 22:23 UTC
rendered paste body
dialog setup {
  size -1 -1 490 299
  title "Chaos Configuration"
  icon images\icones\ $+ %icon,13
  button "&Ok" 1, 328 270 75 24, ok
  list 2, 7 15 154 243, size
  box "" 4, 5 256 479 8
  button "&Cancel" 5, 408 270 75 24, cancel
  list 80, 167 16 314 22, size
  box "" 81, 166 9 318 250
  box "" 82, 167 32 316 8
  text "" 282, 168 40 314 6

  ;general
  check "Servers drop-down menu in toolbar" 6, 178 55 200 15
  edit "" 7, 177 74 240 21, autohs
  button "Add" 8, 346 158 62 20
  button "Remove" 9, 412 158 62 20
  list 10, 177 75 297 80, size sort
  check "Check for updates on connect" 11, 178 193 200 15
  box "" 12, 177 177 297 8
  check "Open News window on connect" 27, 178 213 180 15
  check "Show tips on start" 20, 178 233 150 15

  ;switchbar
  list 133, 177 50 295 90, hide size
  edit "" 135, 234 142 213 21, hide disabled
  button "?" 136, 450 142 22 20, hide
  box "" 137, 177 163 295 8, hide
  text "Status" 138, 177 146 55 15, hide
  check "Highlight Buttons" 139, 178 178 120 15, hide
  check "Flat Buttons" 140, 178 198 100 15, hide
  check "Show active server only" 141, 330 178 137 15, hide
  check "Resize to fit" 142, 330 198 80 15, hide
  list 143, 179 225 295 22, size hide
  box "" 144, 177 217 294 33, hide

  ;themes
  box "" 19, 166 75 318 37
  text "" 212, 167 81 200 29
  text "" 281, 367 82 115 4
  text "Description" 213, 175 89 100 15
  list 214, 353 85 128 24, size
  text "Theme:" 215, 179 54 55 15
  combo 216, 220 50 100 200, drop sort
  text "Scheme:" 217, 328 54 60 15
  combo 218, 375 50 100 200, drop sort
  text "Author:" 219, 177 120 60 15 
  text "E-mail:" 220, 177 140 60 15
  text "Version:" 221, 350 120 60 15
  text "Comment:" 222, 177 160 60 15
  text "" 223, 244 120 60 15
  text "" 224, 405 120 70 15
  link "" 225, 244 140 200 15
  edit "" 226, 243 160 230 85, multi pass vsbar disabled

  button "" 227, 177 120 295 103
  edit "" 297, 177 227 295 20
  text "Under Construction" 289, 265 170 200 15, hide

  list 228, 177 115 295 90, size
  button "Download" 229, 400 228 72 23
  button "Refresh" 230, 324 228 72 23
  text "Ready" 231, 179 231 120 15
  text "" 232, 178 208 293 10

  check "Clear all windows (Recommended)" 283, 178 120 200 15
  check "Modify sidepanel along with theme" 284, 178 140 200 15
  check "Modify DCC Bar along with theme" 296, 178 160 220 15
  check "Color nicknames in nicklist" 290, 178 180 220 15
  check "Alert me when new themes come online" 285, 178 200 220 15
  check "Load random theme on start" 286, 178 220 200 15

  ;display
  check "Enable custom switchbar" 159, 178 55 190 15
  check "Enable statusbar" 21, 178 75 150 15
  check "Enable custom toolbar" 22, 178 95 150 15
  check "Show commands in dialog titlebars" 26, 178 155 190 15
  box "" 43, 167 212 316 8
  text "Icon Package:" 86, 178 232 70 15
  combo 87, 260 227 215 100
  check "Background color" 122, 330 95 100 15
  check "Enable sidepanel" 13, 178 115 100 15
  edit "" 74, 425 113 50 21
  combo 14, 330 113 90 50, drop
  check "Enable Channel WindowFX" 271, 178 135 150 15
  check "I am using a Windows® XP theme" 288, 178 175 190 15

  ;fkeys
  list 40, 177 48 295 200, hide size

  ;about
  text "Created by: Morphy" 41, 177 52 120 15
  text "Contact: morphy_chaos@hotmail.com" 156, 177 68 200 55
  button "Website" 158, 178 228 70 23

  ;sounds
  list 45, 177 48 295 166, hide size
  list 47, 180 220 293 15, size hide
  box "" 145, 178 212 295 36

  ;toolbar
  list 48, 177 45 297 127, hide size
  text "Item name:" 49, 178 181 80 15, hide
  edit "" 50, 240 176 123 21, hide autohs
  text "Command:" 51, 178 229 55 15, hide
  combo 52, 365 177 109 50, hide drop
  edit "" 53, 240 226 123 21, hide autohs
  text "Icon:" 54, 178 205 60 15, hide
  edit "" 55, 240 201 210 21, hide autohs disabled
  button "?" 56, 452 202 21 19, hide
  button "Add" 67, 365 226 53 21, hide
  button "Rem" 68, 420 226 53 21, hide

  ;custom bars
  list 293, 177 50 295 102, size
  button "Disable >" 294, 410 225 62 24, hide
  button "< Enable" 295, 345 225 62 24, hide
  box "Description" 298, 178 151 294 68
  text "Select a custom bar for a brief description." 299, 187 170 250 40


  ;statusbar
  text "Choose the items to be displayed in the statusbar cells, each number represents a cell." 58, 180 50 290 50, hide
  text "1." 59, 190 100 15 15, hide
  text "2." 60, 190 122 15 15, hide
  text "3." 61, 190 144 15 15, hide
  text "4." 62, 190 166 40 15, hide

  combo 63, 230 96 190 60, hide drop
  combo 64, 230 118 190 60, hide drop
  combo 65, 230 140 190 60, hide drop
  combo 66, 230 162 190 60, hide drop

  text "Style:" 160, 190 231 60 15
  combo 161, 230 227 190 60, drop
  box "" 162, 167 210 315 8
  check "Enable mp3 controls" 287, 230 189 200 15

  ;away system
  tab "Reasons" 88, 175 110 297 140
  tab "Advanced" 89,
  list 90, 185 140 277 70, size hide tab 88 vsbar
  button "Remove" 91, 402 215 60 22, hide tab 88
  button "Add", 92, 339 215 60 22, hide tab 88
  check "Log messages" 93, 178 48 100 15, hide
  check "Auto-away after" 94, 178 68 100 15
  edit "" 95, 280 64 35 19, hide
  text "minutes" 96, 320 68 50 15, hide
  check "Change nick" 97, 178 88 80 15
  edit "" 98, 280 86 90 20, autohs hide
  button "" 99, 281 55 6 6, hide
  ; tab2
  check "Set back on key press" 100, 185 145 140 15, hide tab 89
  text "Away Mode:" 101, 185 175 100 15, hide tab 89
  radio "Silent" 102, 270 175 60 18, hide tab 89
  radio "Verbose" 103, 330 175 60 18, hide tab 89
  box "" 104, 185 160 277 8, hide tab 89
  edit "" 105, 186 195 275 17, hide autohs tab 89
  button "" 106, 186 217 275 17, hide autohs tab 89
  text "Current: " 115, 187 219 100 15, hide tab 88

  ;quit messages
  list 107, 177 48 295 172, hide size
  button "Remove" 108, 410 225 62 22, hide
  button "Add" 109, 345 225 62 22, hide
  text "Current:" 110, 179 229 100 15, hide

  ;ctcp replies
  list 111, 177 48 295 172, hide size
  button "Remove" 112, 410 225 62 22, hide
  button "Add" 113, 345 225 62 22, hide
  text "Current:" 114, 179 229 100 15, hide

  ;auto-identify
  list 116, 177 48 295 172, hide size
  button "Remove" 117, 410 225 62 22, hide
  button "Add" 118, 345 225 62 22, hide
  check "Disabled" 119, 178 225 62 22, push
  box "" 120, 338 219 2 28

  ;auto-join
  list 200, 177 68 295 152, hide size
  button "Remove" 201, 410 225 62 22, hide
  button "Add" 202, 345 225 62 22, hide
  check "Disabled" 203, 178 225 62 22, push
  box "" 204, 338 219 2 28
  check "Wait until auto-identified before auto-joining" 292, 178 48 250 15

  ;message blocker
  list 123, 177 48 295 125, hide size
  edit "" 124, 177 178 240 22, hide
  button "+" 125, 420 178 24 22, hide
  button "-" 126, 448 178 24 22, hide
  box "" 127, 177 200 295 8, hide
  check "Exclude notifies" 128, 177 216 180 15, hide
  check "Block all incoming messages" 129, 177 236 180 15, hide
  check "Disabled" 132, 410 230 62 22, hide push

  ;nick completion
  check "Enable nick completion" 146, 178 57 130 15, hide
  box "Display" 147, 177 80 295 93, hide
  edit "" 148, 187 110 273 17, hide autohs
  button "" 149, 187 132 273 17, hide autohs
  text "<nick> - nick of the person you are refering to." 150, 178 205 290 15, hide
  text "Tags:" 151, 178 185 60 15, hide
  text "<message> - your message." 152, 178 221 290 15, hide

  ;modules
  list 153, 177 48 295 200, hide size

  ;updates
  list 154, 177 48 295 110, size
  button "Download" 163, 400 175 72 23
  button "Refresh" 164, 324 175 72 23
  check "Load module when completed" 165, 179 235 195 15
  text "Ready" 166, 179 180 120 15
  box "" 167, 177 200 295 8
  check "Explorer window" 168, 179 215 195 15
  text "" 169, 178 160 293 10

  ;personal protections
  text "Editing:" 170, 179 54 70 15
  combo 171, 225 50 246 100, drop
  box "" 172, 166 75 318 30
  text "" 173, 167 81 315 22
  text "Query Flood" 174, 175 86 200 15

  ; - - text flood
  check "Disabled" 233, 178 225 62 23, push
  text "Punishment:    Ignore user for" 234, 179 193 150 15
  edit "" 235, 345 190 50 20, right limit 4
  text "Trigger:" 236, 179 169 70 15
  edit "" 237, 249 166 50 20, right limit 2
  text "lines in" 238, 305 169 40 15
  edit "" 239, 345 166 50 20, right limit 2
  text "second(s)" 240, 400 169 60 15
  text "This protection triggers when someone tries to write a certain amount of lines in a certain period of time." 241, 179 120 295 43
  text "second(s)" 242, 400 193 60 15

  ; - - ban protection
  check "Disabled" 272, 178 225 62 23, push
  text "Punishment:" 273, 179 160 90 15
  check "Kick user        /        Reason:" 274, 190 180 160 15
  check "Ban user        /" 275, 190 201 100 15
  edit "" 276, 370 176 100 20, autohs
  edit "" 277, 370 197 47 20, right
  text "second(s)" 278, 422 201 100 15
  check "Only for:" 279, 300 200 60 15
  text "This protection triggers when you are banned from a channel where your current status is operator." 280, 179 120 295 30

  ; - - kick protection
  check "Disabled" 243, 178 225 62 23, push
  text "Punishment:" 244, 179 160 90 15
  check "Kick user        /        Reason:" 245, 190 180 160 15
  check "Ban user        /" 246, 190 201 100 15
  edit "" 247, 370 176 100 20, autohs
  edit "" 248, 370 197 47 20, right
  text "second(s)" 249, 422 201 100 15
  check "Only for:" 250, 300 200 60 15
  text "This protection triggers when you are kicked from a channel where your current status is operator." 251, 179 120 295 30

  ; - - badwords
  text "Punishment:" 183, 179 118 100 15
  combo 184, 250 115 221 60, drop
  list 175, 177 140 295 80, size sort
  button "Add" 176, 343 225 62 23
  button "Remove" 177, 410 225 62 23
  check "Disabled" 178, 178 225 62 23, push

  ; - - Excess caps
  text "Punishment:" 187, 179 198 100 15
  combo 188, 250 195 221 60, drop
  text "This type of protection triggers when someone writes a large amount of words with CAPS. You can edit the limit of the allowed words per line." 189, 179 120 295 43
  text "Percentage of words allowed:" 190, 179 173 150 15
  edit "70" 191, 329 169 40 21, limit 2
  check "Disabled" 192, 178 225 62 23, push

  ; - - Channel advertising
  check "Disabled" 199, 178 225 62 23, push
  text "Punishment:" 205, 179 185 100 15
  combo 206, 250 182 221 60, drop
  text "This protection triggers when someone tries to advertise a channel on a private chat with you." 207, 179 120 295 33

  ; - - Excluded nicks
  list 208, 177 120 295 100, size sort
  edit "" 209, 177 225 245 22, autohs
  button "+" 210, 425 226 21 20
  button "-" 211, 450 226 21 20

  ;------------------------------------------

  ;Channel Protections

  ; - - badwords (channel)
  text "Punishment:" 185, 179 118 100 15
  combo 186, 250 115 221 60, drop
  list 179, 177 140 295 80, size
  button "Add" 180, 343 225 62 23
  button "Remove" 181, 410 225 62 23
  check "Disabled" 182, 178 225 62 23, push

  ; - - Excess caps
  text "Punishment:" 193, 179 198 100 15
  combo 194, 250 195 221 60, drop
  text "This type of protection triggers when someone write a large amount of words with CAPS. You can edit the limit of the allowed words per phrase." 195, 179 120 295 43
  text "Percentage of words allowed:" 196, 179 173 150 15
  edit "70" 197, 329 169 40 21, limit 2
  check "Disabled" 198, 178 225 62 23, push


  ;tray icon
  icon 252, 180 51 32 32, system\SysWin.icl,13
  edit "system\SysWin.icl,13" 253, 225 62 220 21, disabled
  button "!" 254, 450 62 20 20
  box "" 255, 177 82 295 8
  check "Display Chaos in Tray" 256, 178 100 130 15
  check "Hide/Show Chaos on double left-click" 257, 178 120 197 15
  check "Popup Menu on right-click" 258, 178 140 190 15
  check "Enable Balloon Tips" 259, 178 160 150 15

  ;help topics
  combo 260, 178 50 120 150, drop
  combo 261, 304 50 167 150, drop sort
  edit "" 262, 177 77 296 170, multi pass autovs vsbar

  ;feedback
  text "From:" 263, 178 64 50 15
  edit "your@mail.here" 264, 225 60 245 21
  text "Subject:" 265, 178 87 60 15
  combo 266, 226 83 244 100, drop
  text "Message:" 267, 178 110 60 15
  edit "" 268, 177 128 295 94, multi pass vsbar autovs return
  button "Send" 269, 401 227 70 22
  text "Standing By..." 270, 178 230 150 15

}

; --------------------------------------------------------------------------------------------------------------

on *:dialog:setup:sclick:8: {
  var %n = $remove($input(Enter server name.,eq,Add server...),:)
  var %s = $input(Enter server.,eq,Add server...)
  if (!%s || !%n) { halt }
  did -a $dname 10 %n $chr(9) %s
  write docs\servers.dat %n $+ : $+ %s
}


on *:dialog:setup:sclick:9: {
  if ( $did($dname,10).sel != $null ) {
    var %s = $calc($did($dname,10).sel -1)
    write -dl $+ %s docs\servers.dat
    did -d $dname 10 $did($dname,10).sel
  } 
}

on *:dialog:setup:sclick:1: {
  set %icon $gettok($did($dname,87).seltext,5-,32) $+ .icl
  set %dmisc2 %dmisc
  unset %dmisc
  unset %mod | unset %mod2 | unset %mod.size
  writeini system\pcfg.sys display xptheme $iif($did($dname,288).state = 1,yes,no)
  if ($did($dname,21).state = 1) { set %dmisc %dmisc statusbar }
  if ($did($dname,22).state = 1) { set %dmisc %dmisc toolbar }
  if ($did($dname,13).state = 1) { set %dmisc %dmisc sidepanel }
  if ($did($dname,26).state = 1) { set %dmisc %dmisc alias }
  if ($did($dname,271).state = 1) { set %dmisc %dmisc winfx }
  if ($did($dname,159).state = 1) { set %dmisc %dmisc switchbar }
  var %k = $did($dname,159).state
  if (%k = 0 && $dialog(sb)) { dialog -x sb sb }
  elseif (%k = 1 && !$dialog(sb)) { dialog -m sb sb }

  if ($did($dname,122).state == 1 && $dialog(tb)) { set %dmisc %dmisc bgcolor | mdx SetDialog tb bgcolor $rgb(222,219,214) | mdx SetColor tb 2 background $rgb(222,219,214) | did -f tb 3 }
  elseif ( $did($dname,122).state = 1 && !$dialog(tb)) { set %dmisc %dmisc bgcolor }
  else { 
    if ($dialog(tb)) { did -i tb 2 1 setbkg none | did -f tb 3  }
  }

  if ($did($dname,287).state = 1) { writeini system\pcfg.sys statusbar mp3 Yes }
  else { writeini system\pcfg.sys statusbar mp3 No }
  if ($did($dname,21).state = 0) { dll system\hos.dll RemStatusBar }
  else { dll system\hos.dll RemStatusBar | statusbar -i }

  if (toolbar isin %dmisc && !$dialog(tb)) { 
    dialog -m tb tb
    tbstatus
  }
  elseif ($dialog(tb) && toolbar !isin %dmisc) {
    dialog -x tb tb
  }
  unset %general
  if ( $did($dname,6).state == 1 ) { set %general %general dropdown }
  if ( $did($dname,11).state == 1 ) { set %general %general updates }
  if ( $did($dname,27).state == 1 ) { set %general %general newz }
  if ( $did($dname,20).state == 1 ) { set %general %general tips }

  unset %sbar.data
  set %sbar.data $sbt(63) $sbt(64) $sbt(65) $sbt(66)

  var %st = $iif($did($dname,161).sel,$did($dname,161).seltext,Regular)
  set %sbar.data %sbar.data $iif(%st = flat,flat,$iif(%st = regular,regular,popout))



  if ($did($dname,13).state = 1 && !$dialog(switchbar)) { sidepanel }
  elseif ($did($dname,13).state = 0 && $dialog(switchbar)) { sidepanel }

  if ($dialog(switchbar)) { nl.update }
  if ($did($dname,14).seltext != $null) { set %sw.pos $ifmatch }
  if ($gettok($did($dname,74),-1,32) < 221 && $gettok($did($dname,74),-1,32) > 149) { 
    set %w1 $calc($gettok($did($dname,74),-1,32)-8) $gettok(%w1,2,32)
    if ($dialog(switchbar)) {
      sidepanel | sidepanel
    }
  }

  if ($dialog(tb)) { tb.refresh }

  if ($dialog(switchbar)) {
    did -i switchbar 45,10 1 clearicons normal
    did -i switchbar 45 1 seticon normal $iif(%icon = qnx.icl,58,0) $+ ,images\icones\ $+ %icon
    did -i switchbar 45 1 seticon normal $iif(%icon = qnx.icl,54,1) $+ ,images\icones\ $+ %icon
    did -i switchbar 10 1 seticon normal 10,system\SysWin.icl
  }

  ;away
  var %l = $did($dname,93).state
  var %a = $did($dname,94).state
  var %t = $did($dname,95).text
  var %c = $did($dname,97).state
  var %n = $did($dname,98).text
  var %an = $did($dname,100).state
  var %m = $did($dname,102).state
  var %am = $did($dname,105).text
  set %away.options %l $+ , $+ %a $+ , $+ $iif(!%t,10,$remove(%t,$chr(44))) $+ , $+ %c $+ , $+ $iif(!%n,$me,$remove(%n,$chr(44))) $+ , $+ %an $+ , $+ %m $+ , $+ %am

  ;quits / ctcp / autoid
  var %q = $gettok($did($dname,110).text,2,35)
  var %cr = $gettok($did($dname,114).text,2,35)
  var %ar = $gettok($did($dname,115).text,2,35)
  var %a = $did($dname,119).state
  var %aj = $did($dname,203).state
  set %messages $iif(!%q,1,%q) $+ , $+ $iif(!%cr,1,%cr) $+ , $+ $iif(!%ar,1,%ar) $+ , $+ %a $+ , $+ %aj

  ;switchbar
  var %a = $did($dname,139).state
  var %b = $did($dname,140).state
  var %c = $did($dname,141).state
  var %d = $did($dname,142).state
  set %sb %a $+ , $+ %b $+ , $+ %c $+ , $+ %d
  if ($dialog(sb)) {
    dialog -x sb sb
    dialog -m sb sb
    update.sb
  }

  writeini system\pcfg.sys misc ajwait $iif($did($dname,292).state = 1,yes,no)

  ;message blocker
  unset %blocker
  set %blocker $iif($did($dname,128).state = 1,notify)
  set %blocker %blocker $iif($did($dname,129).state = 1,all)
  set %blocker %blocker $iif($did($dname,132).state = 1,enabled)

  ;nick completion
  unset %nickcomp
  var %e = $did($dname,146).state
  var %t = $did($dname,148).text
  set %nickcomp %e $+ , $+ $iif(%t,%t,<nick>: <message>)

  ;modules
  unset %modules
  var %m = 2
  while $did($dname,153,%m) {
    var %s = $did($dname,153,%m)
    if ($gettok(%s,5,32) = 2) { .load -rs " $+ $mircdirsystem\remote\ $+ $gettok($gettok(%s,6-,32),1,9) $+ .mrc $+ " }
    else { .unload -rs " $+ $mircdirsystem\remote\ $+ $gettok($gettok(%s,6-,32),1,9) $+ .mrc $+ " | if ($gettok($gettok(%s,6-,32),1,9) = mp3) { .timermp3 off } }
    inc %m
  }
  set %modules $iif($did($dname,165).state = 1,load) $iif($did($dname,168).state = 1,explorer)



  ;sounds
  unset %sounds
  var %s = connect,dis,open,close,part,kick,notice,exit
  var %l = 2
  while $did(setup,45,%l) {
    if ($gettok($did(setup,45,%l), 5, 32) == 2) { set %sounds %sounds $gettok(%s,$calc(%l -1),44) }
    inc %l
  }
  ;protections
  var %b = $iif($did($dname,178).text = enabled,yes,no)
  writeini system\pcfg.sys personal badwords %b  

  var %e = $iif($did($dname,192).text = enabled,yes,no)
  writeini system\pcfg.sys personal excesscaps %e  

  var %c = $iif($did($dname,199).text = enabled,yes,no)
  writeini system\pcfg.sys personal channel %c

  var %t = $iif($did($dname,233).text = enabled,yes,no)
  writeini system\pcfg.sys personal textflood %t

  var %k = $iif($did($dname,243).text = enabled,yes,no)
  writeini system\pcfg.sys personal kickprot %k

  var %b = $iif($did($dname,272).text = enabled,yes,no)
  writeini system\pcfg.sys personal banprot %b

  var %bwp = $gettok($did($dname,184).seltext,1,32)
  writeini system\pcfg.sys personal bwpu %bwp

  var %ecp = $gettok($did($dname,188).seltext,1,32)
  writeini system\pcfg.sys personal ecpu %ecp

  var %cap = $gettok($did($dname,206).seltext,1,32)
  writeini system\pcfg.sys personal capu %cap

  var %tfp = $gettok($did($dname,235).text,1,32)
  writeini system\pcfg.sys personal tfpu %tfp

  var %kppu = $iif($did($dname,245).state = 1,Kick) $iif($did($dname,246).state = 1,Ban)
  if (%kppu) { writeini system\pcfg.sys personal kppu %kppu }
  else { writeini system\pcfg.sys personal kppu none }

  var %bppu = $iif($did($dname,274).state = 1,Kick) $iif($did($dname,275).state = 1,Ban)
  if (%bppu) { writeini system\pcfg.sys personal bppu %bppu }
  else { writeini system\pcfg.sys personal bppu none }

  writeini system\pcfg.sys personal kickreason $iif($did($dname,247).text,$did($dname,247).text,Kick Protection!)
  writeini system\pcfg.sys personal onlyfor $iif($did($dname,250).state = 1,Yes,No)
  writeini system\pcfg.sys personal bantime $iif($did($dname,248).text,$did($dname,248).text,90)

  writeini system\pcfg.sys personal bkickreason $iif($did($dname,276).text,$did($dname,276).text,Ban Protection!)
  writeini system\pcfg.sys personal bonlyfor $iif($did($dname,279).state = 1,Yes,No)
  writeini system\pcfg.sys personal bbantime $iif($did($dname,277).text,$did($dname,277).text,90)


  writeini system\pcfg.sys personal percentage $did($dname,191).text
  if ($did($dname,237).text && $did($dname,237).text !isalpha) { writeini system\pcfg.sys personal tfl $ifmatch }
  if ($did($dname,239).text && $did($dname,239).text !isalpha) { writeini system\pcfg.sys personal tfs $ifmatch }

  ;tray
  writeini system\pcfg.sys tray icon $gettok($did($dname,252),1,32) " $+ $gettok($did($dname,252),2-,32) $+ "
  writeini system\pcfg.sys tray enable $iif($did($dname,256).state = 1,yes,no)
  writeini system\pcfg.sys tray sclick $iif($did($dname,257).state = 1,yes,no)
  writeini system\pcfg.sys tray popups $iif($did($dname,258).state = 1,yes,no)
  writeini system\pcfg.sys tray balloon $iif($did($dname,259).state = 1,yes,no)

  if ($_pcf(tray,enable) = no) { dll system\systray.dll RemoveIcon 10 }
  else { systray | dll system\systray.dll ReplaceIcon 10 > $calc($gettok($_pcf(tray,icon),1,32) +1) $+ , $+ $right($left($gettok($_pcf(tray,icon),2-,32),-1),-1) }

  ;theme options
  var %f = system\pcfg.sys themes
  var %s = $did($dname,284).state
  var %d = $did($dname,296).state

  writeini %f Clear $iif($did($dname,283).state = 1,Yes,No)
  writeini %f Sidepanel $iif(%s = 1,Yes,No)
  writeini %f Update $iif($did($dname,285).state = 1,Yes,No)
  writeini %f Random $iif($did($dname,286).state = 1,Yes,No)
  writeini %f Cline $iif($did($dname,290).state = 1,Yes,No)
  writeini %f DCC $iif(%d = 1,Yes,No)

  if (%s = 1 && %d = 1) { spadjust -a 0 }
  if (%s = 1 && %d = 0) { spadjust -a 1 | spadjust -r 2 }
  if (%s = 0 && %d = 1) { spadjust -a 2 | spadjust -r 1 }
  if (%s = 0 && %d = 0) { spadjust -r 0 }


  ;custom bars
  var %l = 2
  while %l < 5 {
    write -l $+ $calc(%l -1) system\cbars.sys $cell(setup,293,%l,1) $+ $chr(9) $+ $cell(setup,293,%l,2)
    inc %l
  }
  if ($gettok($read(system\cbars.sys,3),2,9) == disabled && $dialog(mp3bar)) { dll system\hos.dll UndockWindow mp3bar }
  if ($gettok($read(system\cbars.sys,1),2,9) == disabled && $dialog(bwbar)) { bwbar }
  if ($gettok($read(system\cbars.sys,2),2,9) == disabled && $dialog(dccbar)) { .timer -m 1 100 dccbar }

  if ($gettok($read(system\cbars.sys,1),2,9) == enabled && !$dialog(bwbar)) { bwbar }
  if ($gettok($read(system\cbars.sys,2),2,9) == enabled && !$dialog(dccbar)) { dccbar }
  if ($gettok($read(system\cbars.sys,3),2,9) == enabled && !$dialog(mp3bar)) { mp3bar }


  ;positions
  unset %expand
  var %b = 2
  while %b <= 5 {
    did -i $dname 2 1 cb root
    set %expand %expand $iif(+e isin $gettok($did($dname,2,%b),1,32),$gettok($did($dname,2,%b),7-,32)) 
    inc %b
  }
  set %expand $iif(!%expand,a,%expand) $+ * $+ %selected
  unset %selected

  if ($window($active)) { window -a " $+ $active $+ " }

}


on *:dialog:setup:init:0: {
  dialog -t $dname Chaos Configuration $iif(alias isin %dmisc,[/setup])
  did -b $dname 11,106,149,166,174,213,231,270,289,285,294,295
  did -m $dname 297
  mdx SetMircVersion $version
  mdx MarkDialog $dname
  dfont $dname 299
  mdx SetControlMDX $dname 2 treeview haslines hasbuttons linesatroot > system\views.mdx
  mdx SetFont $dname 59,60,61,62,80,151,166,174,213,231,270,289 +a 13 600 tahoma
  mdx SetControlMDX $dname 87 ComboBoxEx drop > system\views.mdx
  mdx SetControlMDX $dname 40 listview report rowselect single > system\views.mdx
  mdx SetControlMDX $dname 45 listview report single rowselect checkboxes > system\views.mdx
  mdx SetControlMDX $dname 153 listview sortascending report single infotip rowselect checkboxes > system\views.mdx
  mdx SetControlMDX $dname 47 toolbar flat list nodivider arrows > system\bars.mdx
  mdx SetControlMDX $dname 214,80 toolbar flat list nodivider arrows noresize > system\bars.mdx
  mdx SetControlMDX $dname 143 toolbar $iif($gettok(%sb,2,44) = 1,flat) list nodivider arrows > system\bars.mdx
  mdx SetControlMDX $dname 111,116,10,154,228 listview infotip report showsel single rowselect > system\views.mdx
  mdx SetControlMDX $dname 48,133 listview infotip report showsel single noheader rowselect > system\views.mdx
  mdx SetControlMDX $dname 200 listview infotip report showsel single sortascending rowselect > system\views.mdx
  mdx SetControlMDX $dname 74 UpDown edit alignright numeric > system\ctl_gen.mdx
  mdx SetControlMDX $dname 169,232 Progressbar smooth > system\ctl_gen.mdx
  mdx SetControlMDX $dname 106,149,227 window > system\dialog.mdx
  mdx SetBorderStyle $dname 74 clientedge
  mdx SetBorderStyle $dname 2,105,148 staticedge
  did -i $dname 74 1 $calc($gettok(%w1,1,32) +8) 150 220 1 1:1
  did -m $dname 74
  did -i $dname 48 1 headerdims 170 0 100
  did -i $dname 48 1 headertext Name $tab $+ +c Type $tab Command
  did -i $dname 47,80,143 1 bmpsize 16 16
  mdx SetBorderStyle $dname 47,80,143,214

  did -i $dname 80 1 setimage +nhd 0 icon small 63,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 20,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 33,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 51,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 47,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 26,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 31,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 57,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 16,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 64,images\icones\ $+ %icon

  ; general icons
  did -i $dname 80 1 setimage +nhd 0 icon small 54,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 37,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 36,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 64,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 46,images\icones\ $+ %icon

  did -i $dname 80 1 setimage +nhd 0 icon small 7,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 17,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 55,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 59,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 29,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 13,system\SysWin.icl
  did -i $dname 80 1 setimage +nhd 0 icon small 2,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 11,images\icones\ $+ %icon
  did -i $dname 80 1 setimage +nhd 0 icon small 41,images\icones\ $+ %icon

  did -i $dname 80 1 bwidth 200 200
  did -a $dname 80 1 General Configuration
  mdx SetColor $dname 80 background $rgb(222,219,214)
  did -b $dname 80

  did -i $dname 47 1 pad 5 10
  did -i $dname 47 1 bwidth 97 97
  mdx SetColor $dname 47 background $rgb(222,219,214)
  did -i $dname 47 1 setimage +nhd 0 icon small 61,images\icones\ $+ %icon
  did -i $dname 47 1 setimage +nhd 0 icon small 26,images\icones\ $+ %icon
  did -i $dname 47 1 setimage +nhd 0 icon small 33,images\icones\ $+ %icon
  did -a $dname 47 2 Play $tab $+ Plays selected sound file
  did -a $dname 47 3 Stop $tab $+ Stops playing
  did -a $dname 47 1 Edit $tab $+ Edits selected event's sound file
  did -i $dname 45 1 headerdims 100 189
  did -i $dname 45 1 headertext Event $tab $+ +c Sound file
  did -i $dname 40 1 headerdims 50 220
  did -i $dname 40 1 headertext Key $tab Function

  did -i $dname 87 1 iconsize small
  var %i = $findfile(images\icones\,*.icl,0)
  var %l = 1
  while %l <= %i {
    var %n = $dll(system\zircx.dll,CountIcons, $+ $findfile(images\icones\,*.icl,%l))
    if (%n > 60) {
      did -i $dname 87 1 seticon 0 0, $+ $findfile(images\icones\,*.icl,%l)
      did -a $dname 87 %l %l 0 0 $mp($findfile(images\icones\,*.icl,%l))
    }
    inc %l
  }
  var %c = 2
  while %c <= $calc(%i +1) {
    if (%icon isin $gettok($did(setup,87,%c),5-,32) $+ .icl) { did -c $dname 87 %c }
    inc %c
  }

  did -a $dname 2 $iif(general isin %expand,+e) General
  did -i $dname 2 1 cb root 2
  did -a $dname 2 Away System
  did -a $dname 2 Auto-identify
  did -a $dname 2 Auto-join
  did -a $dname 2 CTCP Replies
  did -a $dname 2 Quit Messages
  did -i $dname 2 1 cb root
  did -a $dname 2 $iif(display isin %expand,+e) Display
  did -i $dname 2 1 cb root 3
  did -a $dname 2 Themes
  did -a $dname 2 Custom Bars
  did -a $dname 2 Switchbar
  did -a $dname 2 Toolbar
  did -a $dname 2 Statusbar
  did -a $dname 2 Nick Completion
  did -i $dname 2 1 cb root
  did -a $dname 2 $iif(protections isin %expand,+e) Protections
  did -i $dname 2 1 cb root 4
  did -a $dname 2 Personal
  did -a $dname 2 Channel
  did -a $dname 2 Message Blocker
  did -i $dname 2 1 cb root
  did -a $dname 2 $iif(modules isin %expand,+e) Modules
  did -i $dname 2 1 cb root 5
  did -a $dname 2 Update
  did -i $dname 2 1 cb root
  did -a $dname 2 $iif(Miscellaneous isin %expand,+e) Miscellaneous
  did -i $dname 2 1 cb root 6
  did -a $dname 2 Sounds
  did -a $dname 2 Function keys
  did -a $dname 2 Tray
  did -i $dname 2 1 cb root
  did -a $dname 2 Help Topics
  did -a $dname 2 Feedback
  did -a $dname 2 About

  did -a $dname 14 Right
  did -a $dname 14 Left
  did -c $dname 14 $didwm($dname,14,%sw.pos)


  hot.list
  if ($_pcf(display,xptheme) = yes) { did -c $dname 288 }
  if (&tod.s = y ) { did -c $dname 20 }
  if (statusbar isin %dmisc) { did -c $dname 21 }
  if (toolbar isin %dmisc) { did -c $dname 22 }
  if (sidepanel isin %dmisc) { did -c $dname 13 }
  if (alias isin %dmisc) { did -c $dname 26 }
  if (bgcolor isin %dmisc) { did -c $dname 122 }
  if (switchbar isin %dmisc) { did -c $dname 159 }
  if (winfx isin %dmisc) { did -c $dname 271 }

  ;GENERAL

  did -i $dname 10 1 headerdims 120 155
  did -i $dname 10 1 headertext Name $chr(9) Server
  var %drop = 1
  while %drop <= $lines(docs\servers.dat) {
    var %n = $gettok($read(docs\servers.dat,%drop),1,58)
    var %s = $gettok($read(docs\servers.dat,%drop),2,58)
    did -a $dname 10 %n $chr(9) %s
    inc %drop
  }

  if (dropdown isin %general) { did -c $dname 6 }
  if (updates isin %general) { did -c $dname 11 }
  if (newz isin %general) { did -c $dname 27 }
  if (tips isin %general) { did -c $dname 20 }


  var %sound = 1
  while %sound <= $lines(docs\sounds.dat) {
    did -a $dname 45 $gettok($read(docs\sounds.dat,%sound),1,42) $tab $lower($nopath($gettok($read(docs\sounds.dat,%sound),2-,42)))
    inc %sound
  }
  if (connect isin %sounds) { did -o setup 45 2 0 0 0 2 $gettok($did(setup,45,2),6-,32) }
  if (dis isin %sounds) { did -o setup 45 3 0 0 0 2 $gettok($did(setup,45,3),6-,32) }
  if (open isin %sounds) { did -o setup 45 4 0 0 0 2 $gettok($did(setup,45,4),6-,32) }
  if (close isin %sounds) { did -o setup 45 5 0 0 0 2 $gettok($did(setup,45,5),6-,32) }
  if (part isin %sounds) { did -o setup 45 6 0 0 0 2 $gettok($did(setup,45,6),6-,32) }
  if (kick isin %sounds) { did -o setup 45 7 0 0 0 2 $gettok($did(setup,45,7),6-,32) }
  if (notice isin %sounds) { did -o setup 45 8 0 0 0 2 $gettok($did(setup,45,8),6-,32) }
  if (exit isin %sounds) { did -o setup 45 9 0 0 0 2 $gettok($did(setup,45,9),6-,32) }

  ;STATUSBAR
  didtok -a $dname 63,64,65,66 44 Server,Network,IP Address,Server Uptime,System Uptime,Time,Idle Time,Date,Nickname,Notify (Online / Offline),Full name,Lag,MP³ Track,Active Window

  did -c $dname 63 $didwm($dname,63,$sbcell(1).type)
  did -c $dname 64 $didwm($dname,64,$sbcell(2).type)
  did -c $dname 65 $didwm($dname,65,$sbcell(3).type)
  did -c $dname 66 $didwm($dname,66,$sbcell(4).type)

  did -a $dname 161 Flat
  did -a $dname 161 Popped Out
  did -a $dname 161 Regular
  did -c $dname 161 $iif(flat isin %sbar.data,1,$iif(popout isin %sbar.data,2,3))
  if ($_pcf(statusbar,mp3) = yes) { did -c $dname 287 | did -c $dname 66 13 | did -b $dname 66 }

  ;TOOLBAR
  var %tb = 1
  while %tb <= $lines(system\tb.sys) {
    if ($read(system\tb.sys,%tb) = -) { inc %tb }
    var %tb.icon = $replace($gettok($read(system\tb.sys,%tb),2,42),$chr(37) $+ icon,%icon)
    did -i setup 48 1 seticon list %tb.icon
    inc %tb

  }
  did -a $dname 52 Normal
  did -a $dname 52 Separator
  did -c $dname 52 1
  var %tb = 1
  var %seps = 0
  while %tb <= $lines(system\tb.sys) {
    if ($read(system\tb.sys,%tb) != - ) {
      did -a $dname 48 +r $calc(%tb - %seps) $calc(%tb - %seps) $gettok($read(system\tb.sys,%tb),1,42) $chr(9) $+ Normal $chr(9) $gettok($read(system\tb.sys,%tb),3-,42) $chr(4) Item name: $gettok($read(system\tb.sys,%tb),1,42) $crlf Type: Normal $crlf Command: $gettok($read(system\tb.sys,%tb),3-,42)
      inc %tb
    }

    else {
      did -a $dname 48 - $tab $+ Separator $chr(4) Separator
      inc %tb
      inc %seps
    }
  }
  ;AWAY
  if (!$gettok(%away.options,8,44)) { set %away.options %away.options $+ › away: <reason> }
  var %a = 1
  while %a <= $lines(docs\reasons.dat) {
    did -a $dname 90 $read(docs\reasons.dat,%a)
    inc %a
  }
  if ($gettok(%away.options,1,44) = 1) { did -c $dname 93 }
  if ($gettok(%away.options,2,44) = 1) { did -c $dname 94 }
  if ($gettok(%away.options,3,44)) { did -a $dname 95 $ifmatch }
  if ($gettok(%away.options,4,44) = 1) { did -c $dname 97 }
  if ($gettok(%away.options,5,44)) { did -a $dname 98 $ifmatch }
  if ($gettok(%away.options,6,44) = 1) { did -c $dname 100 }
  if ($gettok(%away.options,7,44) = 1) { did -c $dname 102 }
  elseif ($gettok(%away.options,7,44) = 0) { did -c $dname 103 }
  if ($gettok(%away.options,8-,44)) { did -a $dname 105 $ifmatch }
  window -lh @away.preview 100 100 277 20
  aline @away.preview $did($dname,105).text
  did -a $dname 106 grab $window(@away.preview).hwnd @away.preview
  did -c $dname 90 $gettok(%messages,3,44) 
  did -ra $dname 115 Current: $chr(35) $+ $did($dname,90).sel

  ;QUITS
  var %q = 1
  while %q <= $lines(docs\quits.txt) {
    did -a $dname 107 $read(docs\quits.txt,%q)
    inc %q
  }

  did -c $dname 107 $gettok(%messages,1,44)
  did -ra $dname 110 Current: $chr(35) $+ $did($dname,107).sel

  ;CTCP
  did -i $dname 111 1 headerdims 80 400
  did -i $dname 111 1 headertext Type $chr(9) Replies
  var %c = 1
  while %c <= $lines(docs\ctcp.txt) {
    did -a $dname 111 $gettok($read(docs\ctcp.txt,%c),1,42) $chr(9) $gettok($read(docs\ctcp.txt,%c),2,42)
    inc %c
  }

  ;AUTO.ID
  did -i $dname 116 1 headerdims 80 80 90 150
  did -i $dname 116 1 headertext Nick $chr(9) Password $chr(9) Network $chr(9) Command
  if ($gettok(%messages,4,44) = 1) { did -ra $dname 119 Enabled | did -c $dname 119 }
  var %a = 1
  while %a <= $lines(docs\id.dat) {
    did -a $dname 116 $gettok($read(docs\id.dat,n,%a),1,32) $chr(9) $str(*,$len($decode($gettok($read(docs\id.dat,n,%a),2,32)))) $chr(9) $cap($gettok($read(docs\id.dat,n,%a),3,32)) $chr(9) $gettok($read(docs\id.dat,n,%a),4-,32)
    inc %a
  }

  ;AUTO.JOIN
  if ($_pcf(misc,ajwait) = yes) { did -c $dname 292 }
  did -i $dname 200 1 headerdims 100 80 90
  did -i $dname 200 1 headertext Channel $chr(9) Network $chr(9) Password
  if ($gettok(%messages,5,44) = 1) { did -ra $dname 203 Enabled | did -c $dname 203 }
  var %a = 1
  while $read(docs\aj.txt,%a) {
    var %r = $read(docs\aj.txt,%a)
    did -a $dname 200 $gettok(%r,1,58) $chr(9) $gettok(%r,2,58) $chr(9) $str(*,$len($decode($gettok(%r,3-,58)))) $chr(4) Channel: $gettok(%r,1,58) $crlf Network: $gettok(%r,2,58)
    inc %a
  }

  ;SWITCHBAR
  unset %times
  did -i $dname 133 1 headerdims 100 173
  did -i $dname 133 1 headertext Window $chr(9) Icon
  var %i = 1
  while %i <= $lines(system\sb.sys) {
    did -i $dname 133 1 seticon list $gettok($read(system\sb.sys,%i),2,9)
    did -a $dname 133 +r %i $chr(160) $gettok($read(system\sb.sys,%i),1,9) $chr(9) $gettok($read(system\sb.sys,%i),2,9)
    inc %i
  }
  did -c $dname 133 2
  did -ra $dname 135 $gettok($read(system\sb.sys,1),2,9)
  if ($gettok(%sb,1,44) = 1) { did -c $dname 139 }
  if ($gettok(%sb,2,44) = 1) { did -c $dname 140 }
  if ($gettok(%sb,3,44) = 1) { did -c $dname 141 }
  if ($gettok(%sb,4,44) = 1) { did -c $dname 142 }

  did -i $dname 143 1 bwidth 92 92
  did -i $dname 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,1),2,9)
  did -i $dname 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,2),2,9)
  did -i $dname 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,3),2,9)
  did -a $dname 143 +cgx $+ $iif($gettok(%sb,3,44) = 1,v) 1 Status $chr(9) $+ Status Window
  did -a $dname 143 +cg 2 #Channel $chr(9) $+ #Channel
  did -a $dname 143 +cg 3 MoRpHy $chr(9) $+ MoRpHy

  ;MESSAGE BLOCKER
  if (notify isin %blocker) { did -c $dname 128 }
  if (all isin %blocker) { did -c $dname 129 }
  if (enable isin %blocker) { did -c $dname 132 | did -ra $dname 132 Enabled }
  var %m = 1
  while %m <= $lines(docs\blocker.dat) {
    did -a $dname 123 $read(docs\blocker.dat,%m)
    inc %m
  }

  ;NICK COMPLETION
  if ($gettok(%nickcomp,1,44) = 1) { did -c $dname 146 }
  did -a $dname 148 $gettok(%nickcomp,2-,44)
  window -lh @nick.comp 100 100 277 20
  if ($did($dname,148).text) { aline @nick.comp $ifmatch }
  did -a $dname 149 grab $window(@nick.comp).hwnd @nick.comp

  ;MODULES
  did -i $dname 153 1 headerdims 150 41 98
  did -i $dname 153 1 headertext Name $chr(9) Ver. $chr(9) Author
  var %f = 1
  var %t = $findfile(system\remote,*.mrc,0)
  while %f <= %t {
    var %x = $findfile(system\remote,*.mrc,%f)
    var %c = $mp($findfile(system\remote,*.mrc,%f))
    var %d = $remove($read($findfile(system\remote,*.mrc,%f),1),;)
    var %v = $remove($read($findfile(system\remote,*.mrc,%f),4),;)
    var %a = $remove($read($findfile(system\remote,*.mrc,%f),3),;)
    if (%c != core && %c != setup && %c != bars && %c != custombars) { did -a $dname 153 0 0 0 $iif($script(%x),2,1) %c $+ $chr(9) %v $chr(9) %a  $chr(4) %d } 
    inc %f
  }

  did -i $dname 154 1 headerdims 150 100 400 80
  did -i $dname 154 1 headertext Name $chr(9) Author $chr(9) Description $chr(9) Size
  did -a $dname 169,232 BarColor $rgb(128,128,128)
  did -a $dname 169,232 0 0 100
  if (load isin %modules) { did -c $dname 165 }
  if (explorer isin %modules) { did -c $dname 168 }

  ;PROTECTIONS
  did -a $dname 171 Text Flood
  did -a $dname 171 Channel advertising
  did -a $dname 171 
  did -a $dname 171 Excess Caps
  did -a $dname 171 Badwords
  did -c $dname 171 $iif(%prot,$gettok(%prot,1,42),1)
  did -ra $dname 174 $did($dname,171).seltext

  did -a $dname 186,194 Kick user
  did -a $dname 186,194 Ban user
  did -a $dname 184,186,188,194,206 Ignore user
  did -a $dname 184,188,206 Close query

  if ($readini(system\pcfg.sys,Personal,Channel) = Yes) { did -c $dname 199 | did -ra $dname 199 Enabled }
  did -ra $dname 191 $readini(system\pcfg.sys,personal,percentage)
  if ($readini(system\pcfg.sys,Personal,ExcessCaps) = Yes) { did -c $dname 192 | did -ra $dname 192 Enabled }
  did -c $dname 188 $didwm($dname,188,$readini(system\pcfg.sys,Personal,ECPu) $+ *)
  if ($readini(system\pcfg.sys,Personal,BadWords) = Yes) { did -c $dname 178 | did -ra $dname 178 Enabled }
  if ($readini(system\pcfg.sys,Personal,KickProt) = Yes) { did -c $dname 243 | did -ra $dname 243 Enabled }
  if ($readini(system\pcfg.sys,Personal,BanProt) = Yes) { did -c $dname 272 | did -ra $dname 272 Enabled }
  if ($_pcf(Personal,textflood) = Yes) { did -c $dname 233 | did -ra $dname 233 Enabled }
  did -ra $dname 237 $_pcf(personal,tfl) | did -ra $dname 239 $_pcf(personal,tfs)
  did -c $dname 184 $didwm($dname,184,$readini(system\pcfg.sys,Personal,BWPu) $+ *)
  did -c $dname 206 $didwm($dname,206,$readini(system\pcfg.sys,Personal,CAPu) $+ *)
  did -a $dname 235 $readini(system\pcfg.sys,Personal,TFPu)
  if (kick isin $_pcf(personal,KPPu)) { did -c $dname 245 }
  if (ban isin $_pcf(personal,KPPu)) { did -c $dname 246 }
  if ($_pcf(personal,KickReason)) { did -ra $dname 247 $ifmatch }
  else { did -ra $dname 247 Kick protection! }
  if ($_pcf(personal,Bantime)) { did -ra $dname 248 $ifmatch }
  else { did -ra $dname 248 90 }
  if ($_pcf(personal,onlyfor) = yes) { did -c $dname 250 }

  if (kick isin $_pcf(personal,BPPu)) { did -c $dname 274 }
  if (ban isin $_pcf(personal,BPPu)) { did -c $dname 275 }
  if ($_pcf(personal,BKickReason)) { did -ra $dname 276 $ifmatch }
  else { did -ra $dname 276 Kick protection! }
  if ($_pcf(personal,BBantime)) { did -ra $dname 277 $ifmatch }
  else { did -ra $dname 277 90 }
  if ($_pcf(personal,bonlyfor) = yes) { did -c $dname 279 }



  var %p = 1
  while $gettok($readini(system\pcfg.sys,personal,bwords),%p,44) {
    did -a $dname 175 $gettok($readini(system\pcfg.sys,personal,bwords),%p,44)
    inc %p
  }
  var %p = 1
  while $gettok($_pcf(personal,excluded),%p,44) {
    did -a $dname 208 $gettok($_pcf(personal,excluded),%p,44)
    inc %p
  }

  mdx SetColor $dname 173,174,212,213,214,281 background $rgb(222,219,214)
  mdx SetColor $dname 174,213,212 textbg $rgb(222,219,214)

  ;THEMES
  mdx SetBorderStyle setup 297 staticedge
  did -i $dname 214 1 bmpsize 16 16
  did -i $dname 214 1 bwidth 22 22
  ;did -a $dname 214 +v 1 View...
  did -i $dname 214 1 setimage +nhd 0 icon small 23,images\icones\ $+ %icon
  did -i $dname 214 1 setimage +nhd 0 icon small 15,images\icones\ $+ %icon
  did -i $dname 214 1 setimage +nhd 0 icon small 22,images\icones\ $+ %icon
  did -i $dname 214 1 setimage +nhd 0 icon small 13,images\icones\ $+ %icon
  did -i $dname 214 1 setimage +nhd 0 icon small 21,images\icones\ $+ %icon
  did -a $dname 214 1 $chr(160) $chr(9) $+ Load
  did -a $dname 214 -
  did -a $dname 214 +cgxG 2 $chr(160) $chr(9) $+ Description
  did -a $dname 214 +cgG 3 $chr(160) $chr(9) $+ Preview
  did -a $dname 214 +cgG 4 $chr(160) $chr(9) $+ Options
  did -a $dname 214 -
  did -a $dname 214 +cgG 5 $chr(160) $chr(9) $+ Get more themes...

  var %f = 1
  while $findfile(system\themes\,*.cts,%f) {
    did -a $dname 216 $cap($mp($findfile(system\themes\,*.cts,%f)))
    inc %f
  }
  did -c $dname 216 $didwm($dname,216,$left(%theme,-4))
  var %t = $did($dname,216).seltext
  if (!%t) { halt }
  var %p = system\themes\ $+ %t $+ .cts
  var %s = 2
  while %s <= $ini(%p,0) {
    did -a $dname 218 $ini(%p,%s)
    inc %s
  }
  did -c setup 218 $didwm(setup,218,$_pcf(themes,scheme))
  did -ra $dname 223 $readini(%p,info,author)
  did -ra $dname 224 $readini(%p,info,version)
  did -ra $dname 225 $readini(%p,info,e-mail)
  did -ra $dname 226 $readini(%p,info,comment)
  .timer -m 1 20 did -f $dname 19

  theme.prev

  did -i $dname 228 1 headerdims 100 100 300 60
  did -i $dname 228 1 headertext Name $chr(9) Author $chr(9) Description $chr(9) Size

  if ($_pcf(themes,clear) = yes) { did -c $dname 283 }
  if ($_pcf(themes,sidepanel) = yes) { did -c $dname 284 }
  if ($_pcf(themes,update) = yes) { did -c $dname 285 }
  if ($_pcf(themes,random) = yes) { did -c $dname 286 }
  if ($_pcf(themes,cline) = yes) { did -c $dname 290 }
  if ($_pcf(themes,dcc) = yes) { did -c $dname 296 }
  did -h $dname 227

  ;TRAY
  if ($_pcf(tray,enable) = yes) { did -c $dname 256 }
  if ($_pcf(tray,sclick) = yes) { did -c $dname 257 }
  if ($_pcf(tray,popups) = yes) { did -c $dname 258 }
  if ($_pcf(tray,balloon) = yes && 9 !isin $os) { did -c $dname 259 }
  if ($_pcf(tray,icon)) { 
    did -g $dname 252 $ifmatch 
    did -ra $dname 253 $gettok($ifmatch,1,32) $+ , $+ $right($left($gettok($ifmatch,2-,32),-1),-1)
  }
  if (9 isin $os) { did -b $dname 259 }

  ;CUSTOM BARS
  mdx SetControlMDX $dname 293 listview report single rowselect showsel > system\views.mdx
  did -i $dname 293 1 headerdims 180 80
  did -i $dname 293 1 headertext Bar $chr(9) Status
  var %l = 1
  while %l <= 4 {
    did -a $dname 293 $read(system\cbars.sys,%l)
    inc %l
  }

  ;HELP TOPICS
  did -m $dname 262
  didtok $dname 260 44 Contents,/Commands
  var %a = 1
  while $findfile(docs\help,*.dat,%a) {
    did -a $dname 261 $mp($ifmatch)
    inc %a
  }
  did -c $dname 260,261 1
  var %l = 1
  var %f = docs\help\ $+ $did($dname,261).seltext $+ .dat
  while %l <= $lines(%f) {
    did -a setup 262 $read(%f,%l)
    did -a setup 262 $chr(13)
    did -a setup 262 $chr(10)
    inc %l
  }

  ;FEEDBACK
  didtok $dname 266 44 Suggestion,Bug Report,Comment,Question
  did -c $dname 266 1

  ;SELECT ITEM
  var %r = $gettok(%expand,2,42)
  set %selected %r
  if (%r) {
    did -i $dname 2 1 cb root $left(%r,-2)
    did -c $dname 2 $right(%r,1)
    hideall
    if (%r = 2) { show.gen }
    elseif (%r = 3) { show.misc }
    elseif (%r = 4) { show.personal }
    elseif (%r = 5) { show.modules }
    elseif (%r = 6) { show.sounds }
    elseif (%r = 7) { show.help }
    elseif (%r = 8) { show.feedback }
    elseif (%r = 9) { show.about }

    elseif (%r = 2 2) { show.away }
    elseif (%r = 2 3) { show.networks }
    elseif (%r = 2 4) { show.autojoin }
    elseif (%r = 2 5) { show.ctcp }
    elseif (%r = 2 6) { show.quits }

    elseif (%r = 3 2) { show.themes }
    elseif (%r = 3 3) { show.custom }
    elseif (%r = 3 4) { show.switch }
    elseif (%r = 3 5) { show.tool }
    elseif (%r = 3 6) { show.sbar }
    elseif (%r = 3 7) { show.nick }

    elseif (%r = 4 2) { show.personal }
    elseif (%r = 4 3) { show.channel }
    elseif (%r = 4 4) { show.advanced }

    elseif (%r = 5 2) { show.update }

    elseif (%r = 6 2) { show.sounds }
    elseif (%r = 6 3) { show.hot }
    elseif (%r = 6 4) { show.tray }
  }
  .timer -m 1 50 mdx SetColor setup 282 background $rgb(face)
}

alias cell {
  return $gettok($gettok($gettok($did($1,$2,$3),$4,9),$iif($4 = 1,6,5) $+ -,32),1,4)
}

on *:dialog:setup:sclick:67: {
  if ( $did($dname,52).sel == 2 ) {
    var %line = $iif($did($dname,48).sel,$calc($did($dname,48).sel -1),$did($dname,48).lines)
    write -il $+ %line system\tb.sys -
  }
  elseif ($did($dname,52).sel == 1 && $did($dname,50).text && $did($dname,55).text && $did($dname,53).text ) {
    var %line = $iif($did($dname,48).sel,$calc($did($dname,48).sel -1),$did($dname,48).lines)
    write -il $+ %line system\tb.sys $did($dname,50).text $+ * $+ $did($dname,55).text $+ * $+ $did($dname,53).text
  }

  .timer -m 1 50 tb.refresh
}

on *:dialog:setup:sclick:68: {
  if ($did($dname,48).sel) {
    var %line = $did($dname,48).sel
    write -dl $+ $calc(%line -1) system\tb.sys
    tb.refresh
  }
}

on *:dialog:setup:sclick:5: {
  unset %expand
  unset %mod | unset %mod2 | unset %mod.size
  var %b = 2
  while %b <= 6 {
    did -i $dname 2 1 cb root
    set %expand %expand $iif(+e isin $gettok($did($dname,2,%b),1,32),$gettok($did($dname,2,%b),7-,32)) 
    inc %b
  }
  set %expand $iif(!%expand,a,%expand) $+ * $+ %selected
  unset %selected
  dialog -x setup setup
}


on *:dialog:setup:sclick:48: {
  var %m = $calc($did($dname,$did).sel -1)
  var %i = $gettok($read(system\tb.sys,%m),2,42)
  did -ra $dname 50 $gettok($read(system\tb.sys,%m),1,42)
  did -ra $dname 55 $iif($read(system\tb.sys,%m) != -,$replace(%i,$chr(37) $+ icon,%icon),n/a)
  did -c $dname 52 $iif($read(system\tb.sys,%m) = -,2,1)
  did -ra $dname 53 $gettok($read(system\tb.sys,%m),3,42)
}

on *:dialog:setup:sclick:56: {
  if (!$dialog(dicons)) { set %tic tool | dialog -m dicons dicons }
}

alias hot.list {
  var %hot = 1
  while %hot <= $lines(docs\hotkeys.dat) {
    did -a setup 40 $gettok($read(docs\hotkeys.dat,%hot),1,32) $tab $gettok($read(docs\hotkeys.dat,%hot),3-,32)
    inc %hot
  }
}

alias hideall {
  did -h setup 6,7,8,9,10,11,12,13,14,19,20,21,22,26,27,40,41,43,45,47,48
  did -h setup 49,50,51,52,53,54,55,56,58,59,60,61,62,63,64,65,66,67,68,74,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100
  did -h setup 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,122,123,124,125,126,127,128,129,132,133
  did -h setup 135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,156,158,159,160,161,162,163,164
  did -h setup 165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192
  did -h setup 193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227
  did -h setup 228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262
  did -h setup 263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,283,284,285,286,287,288,289,290,292,293,294,295,296,297,298,299
}

alias show.switch {
  hideall
  did -v setup 133,135,136,137,138,139,140,141,142,143,144
  did -ra setup 80 4 Switchbar | did -f setup 81,82
}

alias show.gen {
  hideall
  did -v setup 6,8,9,10,11,12,27,20
  did -ra setup 80 1 General Configuration | did -f setup 81,82
}

alias show.custom {
  hideall
  did -v setup 293,294,295,298,299
  did -ra setup 80 24 Custom Bars | did -f setup 81,82
}

alias show.misc {
  hideall 
  did -v setup 21,22,26,43,86,87,122,13,74,14,159,271,288
  did -ra setup 80 2 Display | did -f setup 81,82
}


alias show.hot {
  hideall
  did -v setup 40
  did -ra setup 80 9 Function Keys | did -f setup 81,82
}

alias show.help {
  hideall
  did -v setup 260,261,262
  did -ra setup 80 22 Help Topics | did -f setup 81,82
}

alias show.feedback {
  hideall
  did -v setup 263,264,265,266,267,268,269,270
  did -ra setup 80 14 Feedback | did -f setup 81,82
}

alias show.about {
  hideall
  did -v setup 41,156,158
  did -ra setup 80 23 About Chaos %version | did -f setup 81,82

}

alias show.sounds {
  hideall
  did -v setup 45,47,145
  did -ra setup 80 7 Sounds | did -f setup 81,82

}

alias show.tool {
  hideall
  did -v setup 48,49,50,51,52,53,54,55,56,67,68
  did -ra setup 80 5 Toolbar | did -f setup 81,82
}

alias show.sbar {
  hideall
  did -v setup 58,59,60,61,62,63,64,65,66,160,161,162,287
  did -ra setup 80 6 Statusbar | did -f setup 81,82
}

alias show.away {
  hideall
  did -v setup 88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,115
  did -f setup 81
  did -ra setup 80 11 Away System | did -f setup 81,82
}

alias show.networks {
  hideall
  did -v setup 116,117,118,119,120
  did -ra setup 80 12 Auto-identify | did -f setup 81,82
}

alias show.quits {
  hideall
  did -v setup 107,108,109,110
  did -ra setup 80 13 Quit Messages | did -f setup 81,82
}

alias show.ctcp {
  hideall
  did -v setup 111,112,113
  did -ra setup 80 14 CTCP Replies | did -f setup 81,82
}

alias show.advanced {
  hideall
  did -v setup 123,124,125,126,127,128,129,132
  did -ra setup 80 15 Message Blocker | did -f setup 81,82
}

alias show.nick {
  hideall
  did -v setup 146,147,148,149,150,151,152
  did -ra setup 80 16 Nick Completion | did -f setup 81,82
}

alias show.modules {
  hideall
  did -v setup 153
  did -ra setup 80 17 Modules | did -f setup 81,82
}

alias show.update {
  hideall
  did -v setup 154,163,164,165,166,167,168,169
  did -ra setup 80 17 Modules Update | did -f setup 81,82
}

alias show.themes {
  hideall
  did -v setup 213,212,19,214,215,216,217,218,219,220,221,222,223,224,225,226,281
  did -ra setup 80 20 Themes | did -f setup 81,82
}

alias show.autojoin {
  hideall
  did -v setup 200,201,202,203,204,292
  did -ra setup 80 19 Auto-join | did -f setup 81,82
}

alias show.tray {
  hideall
  did -v setup 252,253,254,255,256,257,258,259
  did -ra setup 80 21 Tray | did -f setup 81,82
}

alias show.personal {
  hideall
  did -r setup 171
  did -a setup 171 Text Flood
  did -a setup 171 Channel advertising
  did -a setup 171
  did -a setup 171 Ban Protection
  did -a setup 171 Kick Protection
  did -a setup 171
  did -a setup 171 Excess Caps
  did -a setup 171 Badwords
  did -a setup 171
  did -a setup 171 Excluded users
  did -v setup 170,171,172,173,174
  did -c setup 171 $iif(%prot,$gettok(%prot,1,42),1)
  did -ra setup 174 $did(setup,171).seltext
  pprot $did(setup,171).seltext
  did -ra setup 80 18 Personal Protections | did -f setup 81,82
}


alias show.channel {
  hideall
  goto pass
  did -r setup 171
  did -a setup 171 Text Flood
  did -a setup 171 Join Flood
  did -a setup 171
  did -a setup 171 Channel Advertising
  did -a setup 171 Excess Caps
  did -a setup 171 Badwords
  did -c setup 171 $iif(%prot,$gettok(%prot,2,42),1)
  cprot $did(setup,171).seltext
  :pass
  did -v setup 172,173,174
  did -ra setup 174 Under Construction
  did -ra setup 80 18 Channel Protections | did -f setup 81,82
}

alias countup {
  var %t = $1-
  var %l = 1
  var %n = 0
  while %l <= $len(%t) {
    var %w = $mid(%t,%l,1)
    if ($isupper(%w) && %w isalpha) { inc %n }
    inc %l
  }
  return $calc(%n *100 / $len(%t))
}


alias pprot {
  var %p = $1-
  if (%p = badwords) { 
    did -v setup 175,176,177,178,183,184
  }
  elseif (%p = excess caps) {
    did -v setup 187,188,189,190,191,192
  }
  elseif (%p = Channel Advertising) {
    did -v setup 199,205,206,207
  }
  elseif (%p = Excluded users) {
    did -v setup 208,209,210,211
  }
  elseif (%p = Text Flood) {
    did -v setup 233,234,235,236,237,238,239,240,241,242
  }
  elseif (%p = Kick Protection) {
    did -v setup 243,244,245,246,247,248,249,250,251
  }
  elseif (%p = Ban Protection) {
    did -v setup 272,273,274,275,276,277,278,279,280
  }
}

alias cprot {
  var %p = $1-
  if (%p = badwords) { 
    did -v setup 179,180,181,182,185,186
  }
  if (%p = excess caps) {
    did -v setup 193,194,195,196,197,198
  }
}

on *:dialog:setup:sclick:47: {
  if ($did($dname,$did).sel == 2 && - !isin $did($dname,45).seltext && $did($dname,45).sel != $null ) { splay $gettok($read(docs\sounds.dat,$calc( $did($dname,45).sel -1)),2-,42) }
  if ($did($dname,$did).sel == 3) { splay -w stop }
  if ($did($dname,$did).sel == 4 && $did($dname,45).sel != $null ) {
    var %file = $mid($gettok($mid($did(setup,45).seltext,13,13),1,9),1,$calc($len($gettok($mid($did(setup,45).seltext,13,13),1,9)-1)))
    var %path.to.file $sfile($mircdir\sounds\)
    if (%path.to.file == $null) { var %path.to.file = - }
    var %path+file %file $+ * $+ %path.to.file
    if ( .wav !isin $mid(%path.to.file,$calc($len(%path.to.file)-3),4) && %path.to.file != - ) { echo -s Choose a valid wave file. | halt }
    write -l $+ $calc($did($dname,45).sel -1) docs\sounds.dat %path+file
    did -r $dname 45
    var %sound = 1
    while %sound <= $lines(docs\sounds.dat) {
      did -a $dname 45 $gettok($read(docs\sounds.dat,%sound),1,42) $tab $nopath($gettok($read(docs\sounds.dat,%sound),2-,42))
      inc %sound
    }
    if (connect isin %sounds) { did -o setup 45 2 0 0 0 2 $gettok($did(setup,45,2),6-,32) }
    if (dis isin %sounds) { did -o setup 45 3 0 0 0 2 $gettok($did(setup,45,3),6-,32) }
    if (open isin %sounds) { did -o setup 45 4 0 0 0 2 $gettok($did(setup,45,4),6-,32) }
    if (close isin %sounds) { did -o setup 45 5 0 0 0 2 $gettok($did(setup,45,5),6-,32) }
    if (part isin %sounds) { did -o setup 45 6 0 0 0 2 $gettok($did(setup,45,6),6-,32) }
    if (kick isin %sounds) { did -o setup 45 7 0 0 0 2 $gettok($did(setup,45,7),6-,32) }
    if (notice isin %sounds) { did -o setup 45 8 0 0 0 2 $gettok($did(setup,45,8),6-,32) }
    if (exit isin %sounds) { did -o setup 45 9 0 0 0 2 $gettok($did(setup,45,9),6-,32) }
  }
}

on *:dialog:setup:sclick:42: {
  if ($did($dname,$did).state = 1) { did -e $dname 85 }
  else { did -b $dname 85 }
} 


on *:dialog:setup:sclick:88: {
  .timer -m 1 10 did -f setup 81
}

on *:dialog:setup:sclick:89: {
  .timer -m 1 10 did -f setup 81
}

on *:dialog:setup:sclick:90: {
  .timer -m 1 10 did -f setup 81
}

on *:dialog:setup:sclick:99: {
  view.log
}

on *:dialog:setup:dclick:90: {
  did -ra $dname 115 Current: $chr(35) $+ $did($dname,$did).sel
}

on *:dialog:setup:dclick:107: {
  did -ra $dname 110 Current: $chr(35) $+ $did($dname,$did).sel
}

on *:dialog:setup:sclick:108: {
  var %l = $did($dname,107).sel
  if (!%l) { halt }
  .write -dl $+ %l docs\quits.txt
  did -d $dname 107 $did($dname,107).sel
}

on *:dialog:setup:sclick:269: {
  if ( *@*.* !iswm $did($dname,264).text ) { did -ra $dname 270 Invalid e-mail address | halt }
  if ( !$did($dname,266) || !$did($dname,268) ) { did -ra $dname 270 Fill out all fields | halt }
  email
}

on *:dialog:setup:sclick:225: {
  if (*@*.* iswm $did($dname,225)) { run mailto: $+ $did($dname,225) }
}

on *:dialog:setup:sclick:214: {
  var %s = $did($dname,$did).sel
  if (%s = 2) { loadthm $did(setup,216).seltext $+ / $+ $did(setup,218).seltext }
  elseif (%s = 4) { theme.description | did -o $dname 214 8 +cGg 5 $chr(160) $chr(9) $+ Get More Themes... }
  elseif (%s = 5) { theme.preview | did -o $dname 214 8 +cGg 5 $chr(160) $chr(9) $+ Get More Themes... }
  elseif (%s = 6) { theme.options | did -o $dname 214 8 +cGg 5 $chr(160) $chr(9) $+ Get More Themes... }
  elseif (%s = 8) { 
    theme.download 
    did -o $dname 214 4 +cGg 2 $chr(160) $chr(9) $+ Description
    did -o $dname 214 5 +cGg 3 $chr(160) $chr(9) $+ Preview
    did -o $dname 214 6 +cGg 4 $chr(160) $chr(9) $+ Options
    did -f $dname 19
  }
  did -f $dname 19
}

;on *:dialog:setup:dclick:214: {
;  did -f $dname 19
;  theme.action.pop
;  do-popup themes $mouse.dx $mouse.dy
;}

;alias theme.action.pop {
;  menu New themes 8 16
;  item themes +d Preview (Under Construction) $cr theme.preview
;  item themes $iif(!$did(setup,216).seltext,+d) Description $cr theme.description
;  item themes +D $+ $iif(!$did(setup,216).seltext || !$did(setup,218).seltext,d) Load $cr loadthm $did(setup,216).seltext $+ / $+ $did(setup,218).seltext
;  item themes
;  item themes Get more themes $cr theme.download
;}

alias theme.description {
  did -ra setup 213 Description
  did -h setup 227,228,229,230,231,232,283,284,285,286,289,290,296,297
  did -v setup 219,220,221,222,223,224,225,226
}

alias theme.preview {
  did -ra setup 213 Preview
  did -h setup 219,220,221,222,223,224,225,226,228,229,230,231,232,283,284,285,286,290,296,289
  did -v setup 227,297
  var %t = $did($dname,216).seltext
  var %s = $did($dname,218).seltext
  var %p = system\themes\ $+ %t $+ .cts

}

alias theme.download {
  did -ra setup 213 Download
  did -h setup 219,220,221,222,223,224,225,226,227,283,284,285,286,289,290,296,297
  did -v setup 228,229,230,231,232
}

alias theme.options {
  did -ra setup 213 Options
  did -h setup 219,220,221,222,223,224,225,226,227,228,229,230,231,232,289,297
  did -v setup 283,284,285,286,290,296
}

on *:dialog:setup:sclick:230: {
  did -r $dname 228
  did -ra $dname 232 0 0 100
  did -ra $dname 231 Connecting...
  themez
}


on *:dialog:setup:sclick:229: {
  if (!$did($dname,228).sel || $cell($dname,228,$did($dname,228).sel,1) = $null) { halt }
  set %get $cell($dname,228,$did($dname,228).sel,1)
  set %get.size $calc($left($cell($dname,228,$did($dname,228).sel,4),-1) *1000)
  sockclose gettheme
  sockopen gettheme pwp.netcabo.pt 80
}

alias theme.load {
  var %t = $gettok($1-,1,47)
  var %s = $gettok($1-,2,47)
  var %p = system\themes\ $+ %t $+ .cts

  var %x = 1
  while $color(%x) {
    color -r %x
    inc %x
  }

  var %x = 1
  while %x < 5 {
    var %c = $gettok($readini(%p,%s,RGB),%x,32))
    var %r = $gettok(%c,1,44)
    var %g = $gettok(%c,2,44)
    var %b = $gettok(%c,3,44)
    echo -s color $calc(%x +3) $rgb(%r $+ , %g $+ , %b)
    inc %x
  }
  var %x = 2
  while $ini(%p,%s,%x) {
    echo -s color $replace($ini(%p,%s,%x),.,$chr(32)) $readini(%p,%s,$ini(%p,%s,%x))
    inc %x
  } 
  if ($readini(%p,format,font)) {
    var %font = $readini(%p,format,font)
    var %fsize = $readini(%p,format,fontsize)
    writeini mirc.ini fonts fstatus $reptok($readini(mirc.ini,fonts,fstatus),$gettok($readini(mirc.ini,fonts,fstatus),1,44),%font %fontsize,44)
  }
}

alias draw.theme {
  drawtext -pb @theme.preview $1-
}

on *:dialog:setup:sclick:119: {
  if ($did($dname,$did).state = 1) { did -ra $dname $did Enabled }
  else { did -ra $dname $did Disabled }
}

on *:dialog:setup:sclick:109: {
  var %q = $$?="Enter Quit Message"
  if (%q) {
    .write docs\quits.txt %q
    did -a $dname 107 $read(docs\quits.txt,$lines(docs\quits.txt))
  }
}

on *:dialog:setup:sclick:112: {
  var %l = $did($dname,111).sel
  if (!%l) { halt }
  var %l = $calc(%l -1)
  .write -dl $+ %l docs\ctcp.txt
  did -d $dname 111 $did($dname,111).sel
}

on *:dialog:setup:sclick:125: {
  if (!$did($dname,124).text) { halt }
  var %t = $did($dname,124).text
  did -a $dname 123 %t
  write docs\blocker.dat %t
  did -r $dname 124
}

on *:dialog:setup:sclick:126: {
  var %l = $did($dname,123).sel
  if (!%l) { halt }
  did -d $dname 123 %l
  write -dl $+ %l docs\blocker.dat
}

on *:dialog:setup:sclick:254: {
  if (!$dialog(dicons)) { set %tic tray | dialog -m dicons dicons }
}

on *:dialog:setup:sclick:113: {
  var %t = $$?"Enter type of reply. (eg. VERSION or TIME)"
  var %r = $$?"Enter reply."
  if (%t && %r) {
    write docs\ctcp.txt $upper(%t) $+ * $+ %r
    did -a $dname 111 $upper(%t) $chr(9) %r
  }
}

on *:dialog:setup:sclick:158: { run www.chaos.page.vu }

on *:dialog:setup:dclick:111: {
  did -ra $dname 114 Current: $chr(35) $+ $calc($did($dname,$did).sel -1)
}

on *:dialog:setup:sclick:118: {
  var %n = $$?="Enter nickname (eg. my_nick)"
  if (!%n) { halt }
  var %p = $$?*"Enter password (eg. password)"
  if (!%p) { halt }
  var %w = $$?="Enter network (eg. Undernet)"
  if (!%w) { halt }
  var %c = $$?="Enter identify command (eg. /nickserv identify)"
  if (!%c) { halt }
  write docs\id.dat %n $encode(%p) %w %c
  did -a $dname 116 %n $chr(9) $str(*,$len(%p)) $chr(9) $cap(%w) $chr(9) %c
}

on *:dialog:setup:sclick:117: {
  if ($did($dname,116).sel) {
    var %l = $did($dname,116).sel
    write -dl $+ $calc(%l -1) docs\id.dat
    did -d $dname 116 %l
  }
}

on *:dialog:setup:sclick:287: {
  if ($did($dname,$did).state = 1) { did -c $dname 66 13 | did -b $dname 66 }
  else { did -e $dname 66 }
}

on *:dialog:setup:sclick:92: {
  var %r = $$?"Enter away reason (eg. i'm out)"
  if (!%r) { halt }
  write docs\reasons.dat %r
  did -a $dname 90 %r
}

on *:dialog:setup:sclick:91: {
  if ($did($dname,90).sel) {
    var %l = $did($dname,90).sel
    write -dl $+ %l docs\reasons.dat
    did -d $dname 90 %l
  }
}

on *:dialog:setup:edit:105: {
  var %m = $did(setup,105).text
  if (%m) { .rline @away.preview 1 %m }
  else { .dline @away.preview 1 }
}

on *:dialog:setup:edit:148: {
  var %m = $did(setup,148).text
  if (%m) { .rline @nick.comp 1 %m }
  else { .dline @nick.comp 1 }
}


on *:dialog:setup:sclick:136: {
  set %tic switch
  if (!$did(setup,133).sel) { halt }
  dicons
}

on *:dialog:setup:sclick:203: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:2: {
  set %tmp $did(2,1)
  set %action $gettok(%tmp, 2, 32)
  if (%action == SELECT) {
    var %root = $gettok(%tmp, 4-, 32)
    var %item = $gettok(%tmp, -1, 32)
    did -i $dname 2 1 cb root %root up
    if ( $gettok(%tmp,4,32) == 2 && !$gettok(%tmp,5,32)) { hideall | show.gen }
    elseif ($gettok(%tmp,4,32) == 2 && $gettok(%tmp,5,32) = 2) { show.away }
    elseif ($gettok(%tmp,4,32) == 2 && $gettok(%tmp,5,32) = 3) { show.networks }
    elseif ($gettok(%tmp,4,32) == 2 && $gettok(%tmp,5,32) = 4) { show.autojoin }
    elseif ($gettok(%tmp,4,32) == 2 && $gettok(%tmp,5,32) = 5) { show.ctcp }
    elseif ($gettok(%tmp,4,32) == 2 && $gettok(%tmp,5,32) = 6) { show.quits }

    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 2 ) { show.themes | did -f $dname 214,215 }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 3 ) { show.custom }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 4 ) { show.switch }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 6 ) { show.sbar }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 7 ) { show.nick }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == 5 ) { show.tool  }
    elseif ( $gettok(%tmp,4,32) == 3 && $gettok(%tmp,5,32) == $null ) { show.misc }

    elseif ( $gettok(%tmp,4,32) = 4 && !$gettok(%tmp,5,32)) { show.personal }
    elseif ( $gettok(%tmp,4,32) == 4 && $gettok(%tmp,5,32) == 2 ) { show.personal }
    elseif ( $gettok(%tmp,4,32) == 4 && $gettok(%tmp,5,32) == 3 ) { show.channel }
    elseif ( $gettok(%tmp,4,32) == 4 && $gettok(%tmp,5,32) == 4 ) { show.advanced }

    elseif ( $gettok(%tmp,4,32) == 5 && $gettok(%tmp,5,32) == $null ) { show.modules }
    elseif ( $gettok(%tmp,4,32) == 5 && $gettok(%tmp,5,32) = 2 ) { show.update }

    elseif ( $gettok(%tmp,4,32) == 6 && !$gettok(%tmp,5,32)) { show.sounds }
    elseif ( $gettok(%tmp,4,32) == 6 && $gettok(%tmp,5,32) = 2 ) { show.sounds }
    elseif ( $gettok(%tmp,4,32) == 6 && $gettok(%tmp,5,32) = 3 ) { show.hot }
    elseif ( $gettok(%tmp,4,32) == 6 && $gettok(%tmp,5,32) = 4 ) { show.tray }
    elseif ( $gettok(%tmp,4,32) == 7 ) { show.help }
    elseif ( $gettok(%tmp,4,32) == 8 ) { show.feedback }
    elseif ( $gettok(%tmp,4,32) == 9 ) { show.about }
  }
  set %selected $gettok(%tmp,4-,32)
  mdx SetColor setup 282 background $rgb(face)
}

on *:dialog:setup:sclick:171: {
  if ($did($dname,$did).seltext) { 
    did -ra $dname 174 $ifmatch
    hideall
    .timer -m 1 50 $iif(%selected = 4 || %selected = 4 2,show.personal,show.channel)
    .timer -m 1 100 did -f $dname $did
    if (%selected = 4 || %selected = 4 2) { set %prot $replace($gettok(%prot,1,42),$gettok(%prot,1,42),$did($dname,$did).sel) $+ * $+ $gettok(%prot,2,42) }
    elseif (%selected = 4 3) { set %prot $gettok(%prot,1,42) $+ * $+ $replace($gettok(%prot,2,42),$gettok(%prot,2,42),$did($dname,$did).sel) }
  }
}

on *:dialog:setup:sclick:260: {
  var %x = $did($dname,261).sel
  did -r $dname 262,261
  var %s = $did($dname,$did).sel
  if (!%s || !%x) { halt }
  if (%s = 1) {
    var %a = 1
    while $findfile(docs\help,*.dat,%a) {
      did -a $dname 261 $mp($ifmatch)
      inc %a
    }
    did -c $dname 261 1
    var %l = 1
    var %f = docs\help\ $+ $did($dname,261).seltext $+ .dat
    while %l <= $lines(%f) {
      did -a setup 262 $read(%f,%l)
      did -a setup 262 $chr(13)
      did -a setup 262 $chr(10)
      inc %l
    }
    did -c $dname 262 1
  }
  else { 
    var %a = 1
    while %a <= $lines(docs\commands.dat) {
      did -a $dname 261 $gettok($read(docs\commands.dat,%a),1,58)
      inc %a
    }
    did -c $dname 261 1
    did -a $dname 262 $gettok($read(docs\commands.dat,w,* $+ $did($dname,261).seltext $+ *),2-,58)
  }
}

on *:dialog:setup:sclick:261: {
  did -r $dname 262
  var %s = $did($dname,260).sel
  if (!%s || !$did($dname,261).sel) { halt }
  if (%s = 1) {
    var %l = 1
    var %f = docs\help\ $+ $did($dname,261).seltext $+ .dat
    while %l <= $lines(%f) {
      did -a setup 262 $read(%f,%l)
      did -a setup 262 $chr(13)
      did -a setup 262 $chr(10)
      inc %l
    }
    did -c $dname 262 1
  }
  else { 
    did -a $dname 262 $gettok($read(docs\commands.dat,w,* $+ $did($dname,261).seltext $+ *),2-,58)
  }
}
on *:dialog:setup:sclick:140: {
  var %s = $did($dname,$did).state
  mdx SetMDXStyle $dname 143 toolbar list nodivider arrows $iif(%s = 1,flat)
}

on *:dialog:setup:sclick:141: {
  var %s = $did($dname,$did).state
  if (%s = 1) { did -o $dname 143 2 +cgv $calc(%times *3 +1) Status $chr(9) $+ Status }
  else { did -o $dname 143 2 +cg $calc(%times *3 +1) Status $chr(9) $+ Status }
  did -f $dname 144

}

on *:dialog:setup:sclick:132: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:133: {
  if ($did($dname,$did).sel) {
    did -ra $dname 138 $mid($gettok($gettok($did($dname,133).seltext,6-,32),1,9),2,10)
    did -ra $dname 135 $gettok($read(system\sb.sys,$calc($did($dname,133).sel -1)),2,9)
  }
}

on *:dialog:setup:sclick:201: {
  if ($did($dname,200).sel) {
    var %a = $read(docs\aj.txt,w,$cell(setup,200,$did($dname,200).sel,1) $+ : $+ $cell(setup,200,$did($dname,200).sel,2) $+ *)
    var %l = $readn
    write -dl $+ %l docs\aj.txt
    did -d $dname 200 $did($dname,200).sel
  }
}

on *:dialog:setup:sclick:202: {
  var %c = $input(Enter channel to add. (eg. #channel),eq,Add to auto-join...)
  if (%c) var %n = $input(Enter network for %c $+ . (eg. DALnet),eq,Add to auto-join...)
  if (%n && %c) { var %p = $input(Enter password for %c $+ . (Optional),eq,Add to auto-join...) }
  if (%n && %c) {
    write docs\aj.txt $+($card(%c),:,$cap(%n),$iif(%p,: $+ $encode(%p)))
    did -a $dname 200 $card(%c) $chr(9) $cap(%n) $iif(%p,$chr(9) $str(*,$len(%p))) $chr(4) Channel: $card(%c) $crlf Network: $cap(%n)
  }
}

alias card {
  if ($mid($1-,1,1) = $chr(35)) { return $1- }
  else { return $chr(35) $+ $1- }
}


on *:dialog:setup:sclick:178: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:192: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:199: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:233: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:243: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:272: {
  did -ra $dname $did $iif($did($dname,$did).state = 1,Enabled,Disabled)
}

on *:dialog:setup:sclick:293: {
  if ($did($dname,293).sel) {
    var %pos = $cell($dname,293,$did($dname,293).sel,3)
    did -ra $dname 298 $cell(setup,$did,$did($dname,293).sel,1)
    did -e $dname 294,295
    if ($cell($dname,$did,$did($dname,293).sel,2) = enabled) { did -b $dname 295 | did -e $dname 294 }
    else { did -b $dname 294 | did -e $dname 295 }
  }
  else { did -b $dname 294,295 | did -ra $dname 298 Description | did -ra setup 299 Select a custom bar for a brief description. }
  if ($did($dname,293).sel = 2) { did -ra setup 299 Shows a graphic of your current DCC Transfers' speeds. Due to docking issues it can't be used if Mp3 is enabled. }
  elseif ($did($dname,293).sel = 3) { did -ra setup 299 Shows a list with your current DCC Transfers as well as information about them such as speed, progress, time left. }
  elseif ($did($dname,293).sel = 4) { did -ra setup 299 Allows you to easily control Chaos Mp3 Player with the player closed. Due to docking issues it can't be used if Bandwidth is enabled. }

}

on *:dialog:setup:sclick:294: {
  var %l = $did($dname,293).sel
  did -o $dname 293 %l $cell($dname,293,%l,1) $chr(9) $+ Disabled $chr(9) $+ $cell($dname,293,%l,3)
  did -c $dname 293 %l
  if ($cell($dname,293,$did($dname,293).sel,2) = enabled) { did -b $dname 295 | did -e $dname 294 }
  else { did -b $dname 294 | did -e $dname 295 }
}

on *:dialog:setup:sclick:295: {
  var %l = $did($dname,293).sel
  if (%l = 2 && $cell(setup,293,4,2) = enabled) { var %i = $input(Due to docking issues $chr(44) the bandwidth bar can't be used if mp3 is enabled. Please disable the mp3 bar before enabling this one.,io,INFO) | halt }
  if (%l = 4 && $cell(setup,293,2,2) = enabled) { var %i = $input(Due to docking issues $chr(44) the mp3 bar can't be used if bandwidth is enabled. Please disable the bandwidth bar before enabling this one.,io,INFO) | halt }
  did -o $dname 293 %l $cell($dname,293,%l,1) $chr(9) $+ Enabled $chr(9) $+ $cell($dname,293,%l,3)
  did -c $dname 293 %l
  if ($cell($dname,293,$did($dname,293).sel,2) = enabled) { did -b $dname 295 | did -e $dname 294 }
  else { did -b $dname 294 | did -e $dname 295 }
}

on *:dialog:setup:sclick:297: {
  var %l = $did($dname,293).sel
  did -o $dname 293 %l $cell($dname,293,%l,1) $chr(9) $+ $cell($dname,293,%l,2) $chr(9) $+ $did($dname,$did).seltext
  did -c $dname 293 %l
}

on *:dialog:setup:sclick:216: {
  var %t = $did($dname,$did).seltext
  if (!%t) { halt }
  var %p = system\themes\ $+ %t $+ .cts
  did -r $dname 218
  var %s = 2
  while %s <= $ini(%p,0) {
    did -a $dname 218 $ini(%p,%s)
    inc %s
  }
  did -c $dname 218 1
  did -ra $dname 223 $readini(%p,info,author)
  did -ra $dname 224 $readini(%p,info,version)
  did -ra $dname 225 $readini(%p,info,e-mail)
  did -ra $dname 226 $readini(%p,info,comment)
  theme.prev
}

on *:dialog:setup:sclick:218: {
  theme.prev
}

alias load.preview {
  var %f = system\themes\ $+ $1 $+ .cts
  var %s = $2
  var %a = 1
  while %a < 5 {
    echo -s color $calc(%a +3) $rgb( [ $gettok($readini(%f,%s,rgb),%a,32) ] )
    inc %a
  }
  drawrect -fr @theme.preview $rgb(255,255,255) 1 0 0 300 300
  draw.theme $rgb(0,0,0) tahoma 11 2 3 (0310:33) $replace($right($readini(%f,format,ChannelEnter),-1),&chan,#preview,4,8,5,9,6,10,7,11)
  draw.theme $rgb(0,0,0) tahoma 11 2 18 (0310:33) $replace($right($readini(%f,format,topic),-1),&topic,Now we have a stupid topic!,4,8,5,9,6,10,7,11)
  draw.theme $rgb(0,0,0) tahoma 11 2 33 (0310:33) $replace($right($readini(%f,format,setby),-1),&nick,Gallagher,&hour,23:45:34,&date,07/01/2003,4,8,5,9,6,10,7,11)
  draw.theme $rgb(0,0,0) tahoma 11 2 48 (0310:34) $replace($right($readini(%f,format,brackets),-1),&nick,Gallagher)  $+ $replace($right($readini(%f,format,text),-1),&text,hey morphy dude,4,8,5,9,6,10,7,11)
  draw.theme $rgb(0,0,0) tahoma 11 2 63 (0310:34) <MoRpHy> How's it hanging?
  draw.theme $rgb(0,0,0) tahoma 11 2 78 (0310:36) › Join: 3Kboy (dawdx@127.34.232.81)
  draw.theme $rgb(0,0,0) tahoma 11 2 93 (0310:36) $replace($right($readini(%f,format,kick),-1),&nick1,Kboy,&nick2,Gallagher,&address1,dawdx@127.34.232.81)
  drawrect -fr @theme.preview $rgb(face) 1 0 109 305 3
  drawrect -fr @theme.preview $rgb(128,128,128) 1 0 112 305 1
  drawrect -fr @theme.preview $rgb(222,219,214) 1 0 113 305 20
  drawtext -rb @theme.preview $rgb(0,0,0) $rgb(222,219,214) tahoma 11 3 114 LOL
  drawdot @theme.preview
}

on *:dialog:setup:sclick:163: {
  if (!$did($dname,154).sel) { halt }
  set %mod $cell($dname,154,$did($dname,154).sel,1)
  set %mod.size $calc($left($cell($dname,154,$did($dname,154).sel,4),-1) *1000)
  if (!%mod) { halt }
  sockclose dmodule
  sockopen dmodule pwp.netcabo.pt 80
}

on *:dialog:setup:sclick:176: {
  var %w = $gettok($remove($input(Enter badword,eq,Add new word...),$chr(44)),1,32)
  if (%w && !$istok($readini(system\pcfg.sys,personal,bwords),%w,44)) {
    writeini system\pcfg.sys personal bwords $addtok($readini(system\pcfg.sys,personal,bwords),%w,44)
    did -a $dname 175 %w
  }
}

on *:dialog:setup:sclick:177: {
  var %w = $did($dname,175).seltext
  if (!%w) { halt }
  if ($did($dname,175).lines > 1) { writeini system\pcfg.sys personal bwords $remtok($readini(system\pcfg.sys,personal,bwords),%w,44) } 
  else { remini system\pcfg.sys personal bwords }
  did -d $dname 175 $did($dname,175).sel
}

on *:dialog:setup:sclick:210: {
  var %w = $gettok($remove($did($dname,209).text,$chr(44)),1,32)
  if (%w && !$istok($readini(system\pcfg.sys,personal,excluded),%w,44)) {
    writeini system\pcfg.sys personal excluded $addtok($readini(system\pcfg.sys,personal,excluded),%w,44)
    did -a $dname 208 %w | did -r $dname 209
  }
}

on *:dialog:setup:sclick:211: {
  var %w = $did($dname,208).seltext
  if (!%w) { halt }
  if ($did($dname,208).lines > 1) { writeini system\pcfg.sys personal excluded $remtok($readini(system\pcfg.sys,personal,excluded),%w,44) } 
  else { remini system\pcfg.sys personal excluded }
  did -d $dname 208 $did($dname,208).sel
}

alias cbw {
  var %a = 1
  while %a <= $numtok($1-,32) {
    if ($istok($readini(system\pcfg.sys,personal,bwords),$gettok($1-,%a,32),44)) { return $true | halt }
    inc %a
  }
  return $false
}   

on *:sockopen:dmodule: {
  if ($sockerr = 0) {
    write -c system\remote\ $+ %mod $+ .mrc
    sockwrite -n $sockname GET /morphy/ $+ %mod $+ .txt
    sockwrite -n $sockname Host: pwp.netcabo.pt $+ $str($crlf ,2)
    if ($dialog(setup)) { did -ra setup 166 Downloading... }
  }
  else {
    if ($dialog(Setup)) { did -ra setup 166 Error downloading! }
  }
}

on *:sockread:dmodule: {
  sockread %mod2
  write system\remote\ $+ %mod $+ .mrc %mod2
  if ($dialog(setup)) { did -a setup 169 $gettok($calc($file(system\remote\ $+ %mod $+ .mrc).size * 100 / %mod.size ),1,46) 0 100 }
  .timermod -m 1 500 mod.complete

}

alias mod.complete {
  if ($dialog(setup)) {
    did -ra setup 166 Download Complete
    did -a setup 169 100 0 100
    if ($did(setup,168).state = 1) { run system\remote }
    if ($did(setup,165).state = 1) { load -rs system\remote\ $+ %mod $+ .mrc }
    unset %mod | unset %mod2 | unset %mod.size
  }
}


on *:dialog:setup:sclick:164: {
  did -a $dname 169 0 0 100
  did -r $dname 154
  did -ra $dname 166 Connecting...
  module.refresh
}

alias module.refresh { sockclose modules | sockopen modules pwp.netcabo.pt 80 }
on *:sockopen:modules: {
  if ($sockerr = 0) {
    sockwrite -n $sockname GET /morphy/modules.txt
    sockwrite -n $sockname Host: pwp.netcabo.pt $+ $str($crlf ,2)
    if ($dialog(setup)) { did -ra setup 166 Connected }
  }
  else {
    if ($dialog(Setup)) { did -ra setup 166 Error connecting! }
  }
}


on *:sockread:modules: {
  sockread %temp
  if ($dialog(setup) && %temp != .) { did -a setup 154 $gettok(%temp,1,42) $chr(9) $gettok(%temp,2,42) $chr(9) $gettok(%temp,3,42) $chr(9) $gettok(%temp,4,42) }
  if (%temp = . && $dialog(setup)) { did -ra setup 166 Ready }
  unset %temp
  halt 
}


alias sidepanel {
  var %t = $dialog(switchbar)
  if (%t) { dll system\hos.dll UndockWindow switchbar }
  else { dialog -m switchbar switchbar | nl.update | window -a " $+ $active $+ " }
}


on *:dialog:setup:sclick:40: {
  if ($gettok($did($dname,$did,1),1,32) = rclick && $did($dname,40).sel != 14 && $did($dname,40).sel != 27) {
    photkeys
  }
}

alias photkeys {
  var %m = $mpdll(MPCreateMenu,photkeys)
  var %h = $gettok(%m,2,32)
  mpcolors photkeys
  var %m = $mpdll(MPAddItem, %h > 1 0 0 $chr(160) Edit > edit.hk)
  var %m = $mpdll(MPAddItem, %h > 2 0 0 $chr(160) Clear > clear.hk)
  var %m = $mpdll(MPopup, photkeys > $mouse.dx $mouse.dy left top right)
}

alias edit.hk {
  var %l = $did(setup,40).sel
  if (!%l) { halt }
  elseif (%l = 6 ) { var %y = $input(Function Key reserved for Configuration.,io,Info) | halt }
  elseif (%l = 3 || %l = 4) { var %y = $input(Function Key reserved for switchbar scrolling.,io,Info) | halt }
  elseif (%l = 18) { var %y = $input(Function Key reserved for window closing.,io,Info) | halt }
  elseif (%l = 12) { var %y = $input(Function Key reserved for log trimming.,io,Info) | halt }
  elseif (%l = 20) { var %y = $input(Function Key reserved for window switching.,io,Info) | halt }
  var %l = $calc(%l -1)
  var %c = $input(Enter command for $cell(setup,40,$calc(%l +1),1),e,Command for $cell(setup,40,$calc(%l +1),1))
  if (!%c) { halt }
  if ($gettok($read(docs\hotkeys.dat,%l),3,32)) {
    .write -l $+ %l docs\hotkeys.dat $gettok($read(docs\hotkeys.dat,%l),1,32) $gettok($read(docs\hotkeys.dat,%l),2,32) $replace($gettok($read(docs\hotkeys.dat,%l),3-,32),$gettok($read(docs\hotkeys.dat,%l),3-,32),%c)
  }
  else {
    .write -l $+ %l docs\hotkeys.dat $gettok($read(docs\hotkeys.dat,%l),1,32) $gettok($read(docs\hotkeys.dat,%l),2,32) %c
  }
  did -o setup 40 $did(setup,40).sel $gettok($read(docs\hotkeys.dat,%l),1,32) $chr(9) $gettok($read(docs\hotkeys.dat,%l),3-,32)
}

alias clear.hk {
  var %l = $did(setup,40).sel
  if (!%l) { halt }
  if (%l = 6) { scid $activecid echo -s › Function Key reserved for configuration. | halt }
  if (%l = 3 || %l = 4) { scid $activecid echo -s › Function Key reserved for switchbar scrolling. | halt } 
  if (%l = 12) { scid $activecid echo -s › Function Key reserved for log trimming. | halt } 
  if (%l = 18) { scid $activecid echo -s › Function Key reserved for window closing. | halt } 
  if (%l = 20) { scid $activecid echo -s › Function Key reserved for window switching. | halt } 
  var %l = $calc(%l -1)
  .write -l $+ %l docs\hotkeys.dat $gettok($read(docs\hotkeys.dat,%l),1,32) $gettok($read(docs\hotkeys.dat,%l),2,32) $remove($gettok($read(docs\hotkeys.dat,%l),3-,32),$gettok($read(docs\hotkeys.dat,%l),3-,32))
  did -o setup 40 $did(setup,40).sel $gettok($read(docs\hotkeys.dat,%l),1,32) $chr(9) $gettok($read(docs\hotkeys.dat,%l),3-,32)

}

alias sbcell {
  var %g = $1
  if ($prop = type) {
    var %a = $gettok(%sbar.data,%g,32)
    if (%a = server) { return Server }
    elseif (%a = network) { return Network }
    elseif (%a = ip) { return IP Address }

    elseif (%a = servup) { return Server Uptime }
    elseif (%a = sysup) { return System Uptime }
    elseif (%a = time) { return Time }
    elseif (%a = idle) { return Idle Time }
    elseif (%a = date) { return Date }

    elseif (%a = nick) { return Nickname }
    elseif (%a = notify) { return Notify (Online / Offline) }
    elseif (%a = name) { return Full name }

    elseif (%a = lag) { return Lag }
    elseif (%a = mp3) { return MP³ Track }
    elseif (%a = active) { return Active Window }
  }

  elseif ($prop = info) {
    var %a = $gettok(%sbar.data,%g,32)
    scid $activecid
    if (%a = server) { return Server: $iif($server,$server,Not Connected) }
    elseif (%a = network) { return Network: $iif($network && $server,$network,Not Connected) }
    elseif (%a = ip) { return IP Address: $ip }

    elseif (%a = servup) { return Server Uptime: $iif($server,$uptime(server,1),n/a) }
    elseif (%a = sysup) { return System Uptime: $uptime(system,1) }
    elseif (%a = time) { return Time: $time }
    elseif (%a = idle) { return Idle Time: $time($idle) }
    elseif (%a = date) { return Date: $fulldate }

    elseif (%a = nick) { return Nickname: $me $iif($away,$chr(40) $+ Away $+ $chr(41)) }
    elseif (%a = notify) { return Notify: $nnicks }
    elseif (%a = name) { return Name: $fullname }

    elseif (%a = lag) { return Lag: $iif($server,%lagb $+ s,n/a) }
    elseif (%a = mp3) { return MP³: $iif($insong,$mp($insong.fname) $chr(40) $+ $mp3.len($calc($insong.pos +1000)) $+ $chr(41) $iif($paused = paused && $insong,(Paused)),Standing By...) }
    elseif (%a = active) { return Active Window: $active $iif($network,$chr(40) $+ $network $+ $chr(41)) }
  }
}

alias sbt {
  var %a = $did(setup,$1).seltext
  if (%a = Server) { return server }
  elseif (%a = Network) { return network }
  elseif (%a = IP Address) { return ip }

  elseif (%a = Server Uptime) { return servup }
  elseif (%a = System Uptime) { return sysup }
  elseif (%a = Time) { return time }
  elseif (%a = Idle Time) { return idle }
  elseif (%a = Date) { return date }

  elseif (%a = Nickname) { return nick }
  elseif (%a = Notify (Online / Offline)) { return notify }
  elseif (%a = Full name) { return name }

  elseif (%a = Lag) { return lag }
  elseif (%a = MP³ Track) { return mp3 }
  elseif (%a = Active Window) { return active }
}


alias ref.sw.pre {
  if (!$dialog(setup)) { halt }
  did -i setup 133,143 1 clearicons normal
  did -r setup 133
  var %i = 1
  while %i <= $lines(system\sb.sys) {
    did -i setup 133 1 seticon list $gettok($read(system\sb.sys,%i),2,9)
    did -a setup 133 +r %i $chr(160) $gettok($read(system\sb.sys,%i),1,9) $chr(9) $gettok($read(system\sb.sys,%i),2,9)
    inc %i
  }
  mdx SetControlMDX setup 143 toolbar $iif($gettok(%sb,2,44) = 1,flat) list nodivider arrows > system\bars.mdx
  did -i setup 143 1 bwidth 92 92
  did -r setup 143
  did -i setup 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,1),2,9)
  did -i setup 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,2),2,9)
  did -i setup 143 1 setimage +nhd 0 icon small $gettok($read(system\sb.sys,3),2,9)
  did -a setup 143 +cg $+ $iif($did(setup,141).state = 1,v) $calc(%times *3 +1) Status $chr(9) $+ Status Window
  did -a setup 143 +cg $calc(%times *3 +2) #Channel $chr(9) $+ #Channel
  did -a setup 143 +cg $calc(%times *3 +3) MoRpHy $chr(9) $+ MoRpHy
  did -f setup 144
}

alias theme.prev {
  var %t = $did(setup,216).seltext
  var %p = system\themes\ $+ %t $+ .cts
  var %s = $did(setup,218).seltext
  var %b = $readini(%p,%s,0)
  if (%t = Dust) {
    var %ed = $readini(%p,%s,c_ed)
    var %edt = $readini(%p,%s,c_edt)
  }
  color 8 %b
  color 9 $readini(%p,%s,1)
  color 11 $readini(%p,%s,2)
  color 12 $readini(%p,%s,3)
  color 13 $readini(%p,%s,6)

  if (!$window(@theme.preview)) window -bph @theme.preview 0 0 300 160
  did -a setup 227 grab $window(@theme.preview).hwnd @theme.preview
  drawrect -fr @theme.preview %b 1 0 0 400 200
  mdx SetFont setup 297 +a - $+ $gettok($readini(%p,%s,font),1,32) 400 $gettok($readini(%p,%s,font),2,32)
  if (%t = Dust) {
    mdx SetColor setup 297 textbg $readini(%p,%s,%ed)
    mdx SetColor setup 297 background $readini(%p,%s,%ed)
    mdx SetColor setup 297 text $readini(%p,%s,%edt)
    did -ra setup 297 hey Dude!
  }
  else {
    mdx SetColor setup 297 textbg $readini(%p,%s,0)
    mdx SetColor setup 297 background $readini(%p,%s,0)
    mdx SetColor setup 297 text $readini(%p,%s,1)
    did -ra setup 297 hey Dude!
  }
  if (%t = chaos) {
    draw.theme 11 8 tahoma 11 2 3 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) 9› Now talking in  $+ #chaos $+  - $date @ $time
    draw.theme 11 8 tahoma 11 2 17 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) › 12Topic9:9 Chaos %version released! Check out www.chaos.page.vu
    draw.theme 11 8 tahoma 11 2 31 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) › 12Set By9:9 Morphy on Thu Sep 11 12@9 10:00:00
    draw.theme 11 8 tahoma 11 2 45 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) 12› Op:12 Chanserv sets mode +o 11 $+ $me
    draw.theme 11 8 tahoma 11 2 59 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) 9‹12@9Spilner $+ › hey $me
    draw.theme 11 8 tahoma 11 2 73 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) 13› Morphy $+  is away (gone fishing)
    draw.theme 11 8 tahoma 11 2 87 $chr(124) $asctime(HH:nn) $chr(124) $str($chr(160),3) 12› Join: 11 $+ Dude  $+ 12( $+ adress@goes.here $+ )
  }
  elseif (%t = Dust) {
    draw.theme 11 8 bright 11 2 3 $strip($timestamp) 9› Now talking in  $+ #chaos $+  - $date @ $time
  }
}

alias thcol {
  if ($1 = 0) { return 8 }
  if ($1 = 1) { return 9 }
  if ($1 = 2) { return 11 }
  if ($1 = 3) { return 12 }
  else { return 13 }
}