menu channel,menubar { 
  Termin Planer:alarm 
}
on *:start:{ 
  set %zeits $time
  set %date $replace($date,/,.)
  if (%wecken == 1) { 
    wecken1 | wecken2 | wecken3 | wecken4 | wecken5 | wecken6 | wecken7 | wecken8 | wecken9 | wecken10
  }
}
alias alarm { 
  if (!$Dialog(wecker)) { .dialog -m wecker wecker }
  Else { .dialog -h wecker wecker }
}
alias -l time_timer { if ($dialog(wecker)) && (!$timer(.time)) { .timer.time 0 1 dialog -t wecker Termin-Planer $chr(160) - $!time uhr - } }
alias wecken1 { if  ($TMPr(planer1,alarm_date) == %date) && ($TMPr(planer1,alarm_time)) && ($TMPr(planer1,alarm_stat) == An) { .timer.wecker1 $TMPr(planer1,alarm_time) 1 1 termin1 } }
alias termin1 { 
  if ($right($TMPr(planer1,ton),3) == wav) { splay sounds\ $+ $TMPr(planer1,ton) }
  $iif($$input(Es ist der $TMPr(planer1,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer1,alarmname)) == $true,.timer.time1 1 120 termin1) 
  TMP Planer1 alarm_date - | TMP planer1 alarm_time -  | TMP planer1 alarmname - | TMP planer1 alarm_stat aus | TMP planer1 ton - | planen 
} 
alias wecken2 { if  ($TMPr(planer2,alarm_date) == %date) && ($TMPr(planer2,alarm_time)) && ($TMPr(planer2,alarm_stat) == An) { .timer.wecker2 $TMPr(planer2,alarm_time) 1 1 termin2 } }
alias termin2 { 
  if ($right($TMPr(planer2,ton),3) == wav) { splay sounds\ $+ $TMPr(planer2,ton) }
  $iif($$input(Es ist der $TMPr(planer2,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer2,alarmname)) == $true,.timer.time2 1 120 termin2) 
  TMP Planer2 alarm_date - | TMP planer2 alarm_time -  | TMP planer2 alarmname - | TMP planer2 alarm_stat aus | planen
} 
alias wecken3 { if  ($TMPr(planer3,alarm_date) == %date) && ($TMPr(planer3,alarm_time)) && ($TMPr(planer3,alarm_stat) == An) { .timer.wecker3 $TMPr(planer3,alarm_time) 1 1 termin3 } }
alias termin3 { 
  if ($right($TMPr(planer3,ton),3) == wav) { splay sounds\ $+ $TMPr(planer3,ton)  }
  $iif($$input(Es ist der $TMPr(planer3,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer3,alarmname)) == $true,.timer.time3 1 120 termin3) 
  TMP Planer3 alarm_date - | TMP planer3 alarm_time -  | TMP planer3 alarmname - | TMP planer3 alarm_stat aus | planen
} 
alias wecken4 { if  ($TMPr(planer4,alarm_date) == %date) && ($TMPr(planer4,alarm_time)) && ($TMPr(planer4,alarm_stat) == An) { .timer.wecker4 $TMPr(planer4,alarm_time) 1 1 termin4 } }
alias termin4 { 
  if ($right($TMPr(planer4,ton),3) == wav) { splay sounds\ $+ $TMPr(planer4,ton)  }
  $iif($$input(Es ist der $TMPr(planer4,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer4,alarmname)) == $true,.timer.time4 1 120 termin4) 
  TMP Planer4 alarm_date - | TMP planer4 alarm_time -  | TMP planer4 alarmname - | TMP planer4 alarm_stat aus | planen
} 
alias wecken5 { if  ($TMPr(planer5,alarm_date) == %date) && ($TMPr(planer5,alarm_time)) && ($TMPr(planer5,alarm_stat) == An) { .timer.wecker5 $TMPr(planer5,alarm_time) 1 1 termin5 } }
alias termin5 { 
  if ($right($TMPr(planer5,ton),3) == wav) { splay sounds\ $+ $TMPr(planer5,ton)  }
  $iif($$input(Es ist der $TMPr(planer5,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer5,alarmname)) == $true,.timer.time5 1 120 termin5) 
  TMP Planer5 alarm_date - | TMP planer5 alarm_time -  | TMP planer5 alarmname - | TMP planer5 alarm_stat aus | planen
} 
alias wecken6 { if  ($TMPr(planer6,alarm_date) == %date) && ($TMPr(planer6,alarm_time)) && ($TMPr(planer6,alarm_stat) == An) { .timer.wecker6 $TMPr(planer6,alarm_time) 1 1 termin6 } }
alias termin6 { 
  if ($right($TMPr(planer6,ton),3) == wav) { splay sounds\ $+ $TMPr(planer6,ton) }
  $iif($$input(Es ist der $TMPr(planer6,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer6,alarmname)) == $true,.timer.time6 1 120 termin6) 
  TMP Planer6 alarm_date - | TMP planer6 alarm_time -  | TMP planer6 alarmname - | TMP planer6 alarm_stat aus | planen
} 
alias wecken7 { if  ($TMPr(planer7,alarm_date) == %date) && ($TMPr(planer7,alarm_time)) && ($TMPr(planer7,alarm_stat) == An) { .timer.wecker7 $TMPr(planer7,alarm_time) 1 1 termin7 } }
alias termin7 { 
  if ($right($TMPr(planer7,ton),3) == wav) { splay sounds\ $+ $TMPr(planer7,ton) }
  $iif($$input(Es ist der $TMPr(planer7,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer7,alarmname)) == $true,.timer.time7 1 120 termin7) 
  TMP Planer7 alarm_date - | TMP planer7 alarm_time -  | TMP planer7 alarmname - | TMP planer7 alarm_stat aus | planen
} 
alias wecken8 { if  ($TMPr(planer8,alarm_date) == %date) && ($TMPr(planer8,alarm_time)) && ($TMPr(planer8,alarm_stat) == An) { .timer.wecker8 $TMPr(planer8,alarm_time) 1 1 termin8 } }
alias termin8 { 
  if ($right($TMPr(planer8,ton),3) == wav) { splay sounds\ $+ $TMPr(planer8,ton) }
  $iif($$input(Es ist der $TMPr(planer8,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer8,alarmname)) == $true,.timer.time8 1 120 termin8) 
  TMP Planer8 alarm_date - | TMP planer8 alarm_time -  | TMP planer8 alarmname - | TMP planer8 alarm_stat aus | planen
} 
alias wecken9 { if  ($TMPr(planer9,alarm_date) == %date) && ($TMPr(planer9,alarm_time)) && ($TMPr(planer9,alarm_stat) == An) { .timer.wecker9 $TMPr(planer9,alarm_time) 1 1 termin9 } }
alias termin9 { 
  if ($right($TMPr(planer9,ton),3) == wav) { splay sounds\ $+ $TMPr(planer9,ton) }
  $iif($$input(Es ist der $TMPr(planer9,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer9,alarmname)) == $true,.timer.time9 1 120 termin9) 
  TMP Planer9 alarm_date - | TMP planer9 alarm_time -  | TMP planer9 alarmname - | TMP planer9 alarm_stat aus | planen
} 
alias wecken10 { if  ($TMPr(planer10,alarm_date) == %date) && ($TMPr(planer10,alarm_time)) && ($TMPr(planer10,alarm_stat) == An) { .timer.wecker10 $TMPr(planer10,alarm_time) 1 1 termin10 } }
alias termin10 { 
  if ($right($TMPr(planer10,ton),3) == wav) { splay sounds\ $+ $TMPr(planer10,ton) }
  $iif($$input(Es ist der $TMPr(planer10,alarm_date) zeit $time !! in 2 min nochmal erinnern ??,iyg,$chr(160) Erinnerung wegen $TMPr(planer10,alarmname)) == $true,.timer.time10 1 120 termin10) 
  TMP Planer10 alarm_date - | TMP planer10 alarm_time -  | TMP planer10 alarmname - | TMP planer10 alarm_stat aus | planen
} 
alias -l TMP {
  if ($exists(data\planer.ini) == $false) { mkdir data | write -c data\planer.ini }
  writeini data\planer.ini $$1 $$2 $$3-
}
alias TMPr {
  if ($exists(data\planer.ini) == $false) { mkdir data | write -c data\planer.ini }
  return $readini data\planer.ini $$1 $$2 
}
alias planen {
  if ($dialog(wecker) != $null) {
    .did -r wecker 1
    .did -az wecker 1  $TMPr(planer1,alarmname).item $Chr(9) $TMPr(planer1,alarm_date).item $Chr(9) $TMPr(planer1,alarm_time).item  $Chr(9) $TMPr(planer1,alarm_stat).item $Chr(9) $TMPr(planer1,ton).item $Chr(9) Planer1  
    .did -az wecker 1  $TMPr(planer2,alarmname).item $Chr(9) $TMPr(planer2,alarm_date).item $Chr(9) $TMPr(planer2,alarm_time).item  $Chr(9) $TMPr(planer2,alarm_stat).item $Chr(9) $TMPr(planer2,ton).item $Chr(9) Planer2  
    .did -az wecker 1  $TMPr(planer3,alarmname).item $Chr(9) $TMPr(planer3,alarm_date).item $Chr(9) $TMPr(planer3,alarm_time).item  $Chr(9) $TMPr(planer3,alarm_stat).item $Chr(9) $TMPr(planer3,ton).item $Chr(9) Planer3  
    .did -az wecker 1  $TMPr(planer4,alarmname).item $Chr(9) $TMPr(planer4,alarm_date).item $Chr(9) $TMPr(planer4,alarm_time).item  $Chr(9) $TMPr(planer4,alarm_stat).item $Chr(9) $TMPr(planer4,ton).item $Chr(9) Planer4 
    .did -az wecker 1  $TMPr(planer5,alarmname).item $Chr(9) $TMPr(planer5,alarm_date).item $Chr(9) $TMPr(planer5,alarm_time).item  $Chr(9) $TMPr(planer5,alarm_stat).item $Chr(9) $TMPr(planer5,ton).item $Chr(9) Planer5  
    .did -az wecker 1  $TMPr(planer6,alarmname).item $Chr(9) $TMPr(planer6,alarm_date).item $Chr(9) $TMPr(planer6,alarm_time).item  $Chr(9) $TMPr(planer6,alarm_stat).item $Chr(9) $TMPr(planer6,ton).item $Chr(9) Planer6  
    .did -az wecker 1  $TMPr(planer7,alarmname).item $Chr(9) $TMPr(planer7,alarm_date).item $Chr(9) $TMPr(planer7,alarm_time).item  $Chr(9) $TMPr(planer7,alarm_stat).item $Chr(9) $TMPr(planer7,ton).item $Chr(9) Planer7  
    .did -az wecker 1  $TMPr(planer8,alarmname).item $Chr(9) $TMPr(planer8,alarm_date).item $Chr(9) $TMPr(planer8,alarm_time).item  $Chr(9) $TMPr(planer8,alarm_stat).item $Chr(9) $TMPr(planer8,ton).item $Chr(9) Planer8  
    .did -az wecker 1  $TMPr(planer9,alarmname).item $Chr(9) $TMPr(planer9,alarm_date).item $Chr(9) $TMPr(planer9,alarm_time).item  $Chr(9) $TMPr(planer9,alarm_stat).item $Chr(9) $TMPr(planer9,ton).item $Chr(9) Planer9  
    .did -az wecker 1  $TMPr(planer10,alarmname).item $Chr(9) $TMPr(planer10,alarm_date).item $Chr(9) $TMPr(planer10,alarm_time).item  $Chr(9) $TMPr(planer10,alarm_stat).item $Chr(9) $TMPr(planer10,ton).item $Chr(9) Planer10  
  }
}
alias lieder { 
  .remove -t lista.txt
  .did -r $dname 13 
  set %totale $findfile(C:\Drachen-Script\sounds\,*.wav,0)
  var %i = 1 
  while %totale >= %i {
    set %mp3.find $findfile(C:\Drachen-Script\sounds\,*.wav,%i) 
    .write lista.txt %mp3.find 
    inc %i
    did -a $dname 13 $nopath(%mp3.find)
  } 
}
alias mdx-info {
  var %dname, %did
  if ($0 = 1) {
    set %dname $dname
    set %did $1
  }
  else {
    set %dname $1
    set %did $2
  }
  did -i %dname %did 1 page $prop
  return $gettok($did(%dname, %did, 1), 3-, 32)
}
alias lösch {
  TMP $did(2).text alarm_stat aus | TMP $did(2).text alarm_date - | TMP $did(2).text alarm_time -  | TMP $did(2).text alarmname - | TMP $did(2).text alarm_stat aus | TMP $did(2).text ton - | planen 
  planen  
}
alias sset { TMP $did(2).text ton $did(13).seltext |  planen }
dialog Wecker {
  title "Termin Planer"
  size -1 -1 281 120
  option dbu
  icon icon.ico, 0
  list 1, 3 26 271 90, size
  edit "", 2, 3 14 29 10, disable
  edit "30.04.2006", 3, 32 14 35 10, limit 10
  edit "", 4, 67 14 22 10, limit 5
  edit "Test the best", 5, 89 14 71 10
  check "An", 6, 300 12 15 10, left
  check "Start bei Connect", 7, 3 3 53 10
  check "Audio an", 8, 78 3 31 10
  edit "", 9, 8 180 99 10
  button "Anhören", 10, 176 3 31 9
  button "Starten", 11, 162 15 22 9
  button "Löschen", 12, 185 15 24 9
  combo 13, 112 2 60 50, size drop
}
on *:dialog:wecker:*:*:{
  if ($devent == init) {
    dll $mdx Dialog $dname $dialog($dname).hwnd
    dll $mdx  SetControlMDX 1 listview report grid showsel rowselect labeltip editlabels rowselect > $views
    did -i wecker 1 1 headerdims  155:1 80:2 60:3 50:4 100:5 60:6
    did -i $dname 1 1 setbkg url tile $mircdirsystem\images\clock.gif
    did -i wecker 1 1 headertext Termin $Chr(9) Datum $Chr(9) Uhrzeit $Chr(9) Start $Chr(9) Ton $Chr(9) PlanerNR.
    dll $mdx SetMircVersion $version
    dll $mdx SetDialog $dname style title sysmenu 
    dll $mdx SetBorderStyle $dname 1,2,3,4,5 staticedge
    dll $mdx SetColor 2 background $rgb(255,255,255)
    dll $mdx SetColor 2 textbg $rgb(255,255,255)
    dll $mdx SetColor 2 text $rgb(0,0,100)

    planen
    dialog -t wecker $chr(160) Erinnerungs-Kalender - $time uhr -
    time_timer
    did -o $dname 9 9 $nopath(%al_sound) 
    if (%al_sounds == 1) { did -c $dname 8 }
    if (%wecken == 1) { did -c $dname 7 }
    did -o $dname 4 1 $left(%zeits, 5)
    lieder
    did -ro $dname 3 1 %date
    did -c $dname 13 %afilesel 
  }
  if ($devent == dclick) {
    if ($did = 1) {
      did -ro $dname 2 1  $right($Did(wecker , 1, 1).seltext, 9) | did -ro $dname 3 1 $TMPr($did(2).text,alarm_date) | did -ro $dname 4 1 $TMPr($did(2).text,alarm_time) | did -ro $dname 5 1 $TMPr($did(2).text,alarmname) | did -c $dname 13 $TMPr($did(2).text,afilesel) | if $TMPr($did(2).text,alarm_date) == An) did -c $dname 6
    }
  }
  if ($devent == sclick) {
    if ($did = 1) {
      did -ro $dname 2 1  $right($Did(wecker , 1, 1).seltext, 9)
      var %action = $gettok($did($dname,$did,1),1,32)
      if ( %action == endlabeledit ) { TMP $did(2).text alarmname $mdx-info($dname,$did).labeledit
        planen      
      }
      var %t = $did(1,1),%a = $gettok(%t,1,32)
      if (%a == rclick) {
        var %menu = $dname,%result
        popupdllNew %menu 16 16
        popupdllicon %menu $ico(2)
        popupdllicon %menu $ico(45)
        popupdllicon %menu $ico(3)
        var %t = $did(%d,1,$gettok(%t,4,32)) 
        var %n = $gettok(%t,7,32)
        var %r = $read($notifyfile,w,%n $+ *)
        if ( %cantbeassed == 3 ) {
          popupdllAddItem %menu end %f 0 0 Zuletzt online: $iif($asctime($gettok(%r,2,126)),$ifmatch Signing $gettok(%r,3,126),n/a)
          popupdllAddItem %menu end +
        }
        popupdllAddItem %menu end $+(%f,%ff) 1 1 &Termin löschen $cr lösch 
        popupdllAddItem %menu end $+(%f,%ff) 2 2 &Obrigen Sound setzen $cr sset
        popupdllAddItem %menu end $+(%f,%ff) 3 3 &Kein sound $cr keinsong

        popupdllPopup %menu + $mouse.dx $mouse.dy
        %result = $result
        popupdllDestroy %menu
        if ($gettok(%result,1,32) == OK) && ($gettok(%result,4-,32)) { $ifmatch }
      }
    }
    if ($did = 7) { set %wecken $did(7).state }
    if ($did = 11) {
      TMP $did(2).text alarm_date $did(3).text | TMP $did(2).text alarm_time $did(4).text | TMP $did(2).text alarmname $did(5).text | TMP $did(2).text alarm_stat An | TMP $did(2).text afilesel %afilesel
      if (%al_sounds == 1) { TMP $did(2).text ton $did(13).seltext } | if ($did(2).text == Planer1) { wecken1 } | if ($did(2).text == Planer2) { wecken2 } | if ($did(2).text == Planer3) { wecken3 } | if ($did(2).text == Planer4) { wecken4 } | if ($did(2).text == Planer5) { wecken5 } | if ($did(2).text == Planer6) { wecken6 } | if ($did(2).text == Planer7) { wecken7 } | if ($did(2).text == Planer8) { wecken8 } | if ($did(2).text == Planer9) { wecken9 } | if ($did(2).text == Planer10) { wecken10 } 
      planen   
    }
    if ($did = 12) {
      ;TMP $did(2).text alarm_stat aus | TMP $did(2).text alarm_date - | TMP $did(2).text alarm_time -  | TMP $did(2).text alarmname - | TMP $did(2).text alarm_stat aus | TMP $did(2).text ton - | planen 
      ;planen 
      lösch  
    }
    if ($did = 6) {
      if ($did(6).state == 1) {
        TMP $did(2).text alarm_date $did(3).text
        TMP $did(2).text alarm_time $did(4).text
        TMP $did(2).text alarmname $did(5).text
        TMP $did(2).text alarm_stat An
        TMP $did(2).text al_sounds $did(8).state
        if ($did(2).text == Planer1) { wecken1 }       
        if ($did(2).text == Planer2) { wecken2 }
        if ($did(2).text == Planer3) { wecken3 }       
        if ($did(2).text == Planer4) { wecken4 }  
        if ($did(2).text == Planer5) { wecken5 }  
        if ($did(2).text == Planer6) { wecken6 }  
        if ($did(2).text == Planer7) { wecken7 }  
        if ($did(2).text == Planer8) { wecken8 }  
        if ($did(2).text == Planer9) { wecken9 }  
        if ($did(2).text == Planer10) { wecken10 }        
      }
      else { TMP $did(2).text alarm_stat aus | TMP $did(2).text alarm_date - | TMP $did(2).text alarm_time -  | TMP $did(2).text alarmname - | TMP $did(2).text alarm_stat aus | planen }
      planen    
    }
    if ($did = 8) { set %al_sounds $did(8).state }
    if ($did = 10) { .splay $did(13).seltext }
    if ($did = 13) { set %al_sound $did(13).seltext | set %afilesel $did(13).sel }
  }
  if ($devent == close) { .timer.time off }
}
alias keinsong {
  TMP $did(2).text ton - 
  planen
}
