This is a calendar dialog script. You open the channel popup menu, click 'CalliCalendar' enter a year, which will open the Calendar, months are arranged into tabs, each with a respective amount of buttons, indicating the dates within that month. Click a date to open a second dialog, where you can enter information etc for that day, and click submit. This info is written to an .ini file. A file is created for each year, and they are divided into sections, named after the months, and each month has a list of items, indicating the dates, and each value is the information entered for that day. To determine whether the 29th of February is to be shown, I wrote an identifier called $leapyear (Usage: $leapyear(year) ). The identifier is included. There is a function called Auto-Alert that will automatically bring up the box for the current date when mirc is loaded (initialization script warning should be turned off for convenience), if this option is enabled, it can be changed from the channel menu. There is a 5-Day-Calender part, that will have buttons for the next 5 Days, so you can check upcoming dates. On the main Calendar, days that there is information written for will have an asterisk(*) symbol, so you will know which days you have things scheduled for, without clicking all the buttons.
Any feedback will be greatly appreciated and any ideas for improving will be considered.
I hope you like it.
In order to add the 5-Day-Calendar i added the $specday identifier, if no parameters are provided, it will return the name of the current day(exactly like $day), but if a parameter is provided, N days will be added, and it will return that day, for example, if the day is Friday, $specday(1) will return 'Saturday', $specday(-1) will return 'Thursday' and $specday(4) will return 'Tuesday'. I also added $mdays() which will return the amount of days in the month N (the month must be provided as a number from 1-12) in year M. (In the format of $mdays(N,M))
dialog Calendar {
title ""
size -1 -1 360 100
option dbu
tab "January", 1, 0 0 400 150
tab "February", 2
tab "March", 3
tab "April", 4
tab "May", 5
tab "June", 6
tab "July", 7
tab "August", 8
tab "September", 9
tab "October", 10
tab "November", 11
tab "December", 12
button "Done", 44, 300 70 50 20, ok
button "5-Day-Calendar", 45, 240 70 50 20
button "1", 13, 5 20 20 20
button "2", 14, 30 20 20 20
button "3", 15, 55 20 20 20
button "4", 16, 80 20 20 20
button "5", 17, 105 20 20 20
button "6", 18, 130 20 20 20
button "7", 19, 155 20 20 20
button "8", 20, 180 20 20 20
button "9", 21, 205 20 20 20
button "10", 22, 230 20 20 20
button "11", 23, 255 20 20 20
button "12", 24, 280 20 20 20
button "13", 25, 305 20 20 20
button "14", 26, 330 20 20 20
button "15", 27, 5 45 20 20
button "16", 28, 30 45 20 20
button "17", 29, 55 45 20 20
button "18", 30, 80 45 20 20
button "19", 31, 105 45 20 20
button "20", 32, 130 45 20 20
button "21", 33, 155 45 20 20
button "22", 34, 180 45 20 20
button "23", 35, 205 45 20 20
button "24", 36, 230 45 20 20
button "25", 37, 255 45 20 20
button "26", 38, 280 45 20 20
button "27", 39, 305 45 20 20
button "28", 40, 330 45 20 20
button "29", 41, 5 70 20 20
button "30", 42, 30 70 20 20
button "31", 43, 55 70 20 20
}
dialog calentry {
title ""
size -1 -1 140 160
option dbu
text "Enter your info", 1, 10 10 100 15
edit "" 2, 10 20 120 120, multi vsbar
button "Submit" 3, 35 143 20 12, ok
button "5-Day-Calendar" 4, 60 143 45 12
}
menu channel {
CalliCalendar
.Calendar: { if (( $dialog(calendar) )) { goto open }
set %year $$?="For which year?"
if (( %year !isnum )) { unset %year | halt }
:open
dialog $iif($dialog(calendar),-v,-mdo) Calendar Calendar
}
.Auto Alert
..$iif(%autotoday == on,Off,On) $+ : $iif(%autotoday == on,unset %autotoday,set %autotoday on) | noop $input(Auto-Alert is now $iif(%autotoday,on,off),o,Auto-Alert)
.5-Day-Calendar:dialog -mo upcoming upcoming
}
on *:dialog:*:*:*: {
if (( $dname == Calendar )) {
if (( $devent == init )) {
dialog -t calendar Calendar for %year
unset %year
var %amz = 13
while (( %amz <= 43 )) {
if (( $readini( $+(Calendar,$gettok($dialog($dname).title,3,32),.ini) , n , $did(Calendar,$dialog(Calendar).tab) , $ord($did(%amz)) ) != $null )) { did -a Calendar %amz $did(%amz) $+ * }
inc %amz
}
}
if (( $devent == sclick )) {
if (( $did isnum 13-43 )) {
dialog $iif($dialog($month($dialog($dname).tab) $+ $did($did)),-v,-mo) $month($dialog($dname).tab) $+ . $+ $remove($did($did),$chr(42)) $+ . $+ $gettok($dialog($dname).title,3,32) Calentry
}
if (( $did == 4 )) || (( $did == 6 )) || (( $did == 9 )) || (( $did == 11 )) { did -h Calendar 43 | did -v Calendar 42,41 }
if (( $did == 1 )) || (( $did == 3 )) || (( $did == 5 )) || (( $did == 7 )) || (( $did == 8 )) || (( $did == 10 )) || (( $did == 12 )) did -v Calendar 43,42,41
if (( $did == 2 )) { did -h Calendar 43,42
if (( !$leapyear($gettok($dialog($dname).title,3,32)) )) { did -h Calendar 41 }
}
if (( $did == 45 )) {
dialog -mo Upcoming Upcoming
}
if (( $did isnum 1-12 )) {
var %ghj = 13
while (( %ghj <= 43 )) {
did -a Calendar %ghj $calc(%ghj - 12)
inc %ghj
}
var %amz = 13
while (( %amz <= 43 )) {
if (( $readini( $+(Calendar,$gettok($dialog($dname).title,3,32),.ini) , n , $did(Calendar,$dialog(Calendar).tab) , $ord($did(%amz)) ) != $null )) { did -a Calendar %amz $did(%amz) $+ * }
inc %amz
}
}
}
}
if (( $dialog($dname).table == Calentry )) {
if (( $devent == init )) {
dialog -t $dname $gettok($dname,1,46) $ord($gettok($dname,2,46)) $gettok($dname,3,46)
did -a $dname 2 $readini( $+(Calendar,$gettok($dialog($dname).title,3,32),.ini), n , $gettok($dialog($dname).title,1,32) , $gettok($dialog($dname).title,2,32) )
}
if (( $devent == sclick )) {
if (( $did == 3 )) {
remini $+(Calendar,$gettok($dialog($dname).title,3,32),.ini) $gettok($dialog($dname).title,1,32) $gettok($dialog($dname).title,2,32)
var %z = 1
while (( %z <= $did(2).lines )) {
$iif($did(2),writeini $+(Calendar,$gettok($dialog($dname).title,3,32),.ini) $gettok($dialog($dname).title,1,32) $gettok($dialog($dname).title,2,32) $readini($+(Calendar,$gettok($dialog($dname).title,3,32),.ini),n,$gettok($dialog($dname).title,1,32),$gettok($dialog($dname).title,2,32)) $did($dname,2,%z))
inc %z
}
if (( $dialog(Calendar) )) && (( $did(Calendar,$dialog(Calendar).tab,1) == $gettok($dialog($dname).title,1,32) )) && (( $did($dname,2,1) != $null )) { did -a Calendar $calc($left($gettok($dialog($dname).title,2,32),-2) + 12) $gettok($dname,2,46) $+ * }
if (( $dialog(Calendar) )) && (( $did(Calendar,$dialog(Calendar).tab,1) == $gettok($dialog($dname).title,1,32) )) && (( $did($dname,2,1) == $null )) { did -a Calendar $calc($left($gettok($dialog($dname).title,2,32),-2) + 12) $remove($gettok($dname,2,46),$chr(42)) }
}
if (( $did == 4 )) {
dialog -mo Upcoming Upcoming
dialog -x $dname
}
}
}
if (( $dname == upcoming )) {
if (( $devent == init )) {
did -a upcoming 1 $day $int($ord($gettok($date,1,47))) $month $gettok($date,3,47))
did -a upcoming 2 $specday(+1) $int($ord($gettok($specdate(1),1,47))) $month($gettok($specdate(1),2,47)) $gettok($specdate(1),3,47))
did -a upcoming 3 $specday(+2) $int($ord($gettok($specdate(2),1,47))) $month($gettok($specdate(2),2,47)) $gettok($specdate(2),3,47))
did -a upcoming 4 $specday(+3) $int($ord($gettok($specdate(3),1,47))) $month($gettok($specdate(3),2,47)) $gettok($specdate(3),3,47))
did -a upcoming 5 $specday(+4) $int($ord($gettok($specdate(4),1,47))) $month($gettok($specdate(4),2,47)) $gettok($specdate(4),3,47))
}
if (( $devent == sclick )) {
if (( $did isnum 1-5 )) {
dialog -mo $+($gettok($did($did),3,32),.,$gettok($did($did),2,32),.,$gettok($did($did),4,32)) Calentry
}
}
}
}
alias leapyear {
if (( 4 // $1 )) return $true
else return $false
}
alias month {
if (( $1 == $null )) { var %i = $gettok($date,2,47) }
else { var %i = $1 }
var %i = $calc(%i)
return $gettok(January February March April May June July August September October November December,%i,32)
}
on *:start: {
if (( %autotoday == on )) {
dialog -mo $+($month,.,$int($gettok($date,1,47)),.,$gettok($date,3,47)) Calentry
}
}
dialog upcoming {
title "5 Day Calendar"
size -1 -1 110 115
option dbu
button "", 1, 10 15 90 15
button "", 2, 10 35 90 15
button "", 3, 10 55 90 15
button "", 4, 10 75 90 15
button "", 5, 10 95 90 15
text "5-Day-Calendar" 6, 10 5 90 10
}
alias specday {
if (( $1 == $null )) || (( $1 == 0 )) { return $day }
if (( $1 !isnum )) { return $null }
var %f = $findtok(Monday Tuesday Wednesday Thursday Friday Saturday Sunday,$day,1,32)
inc %f $1
:again1
if (( %f > 7 )) { var %f = $calc( %f - 7 ) | goto again1 }
:again2
if (( %f <= 0 )) { var %f = $calc( %f + 7 ) | goto again2 }
return $gettok(Monday Tuesday Wednesday Thursday Friday Saturday Sunday,%f,32)
}
alias -l specdate {
var %i = $puttok($date,$calc($gettok($date,1,47) + $1),1,47)
if (( $gettok(%i,1,47) > $mdays($gettok($date,2,47),$gettok($date,3,47)) )) {
var %i = $puttok(%i,$calc($gettok(%i,1,47) - $mdays($gettok($date,2,47),$gettok($date,3,47))),1,47)
var %i = $puttok(%i,$calc($gettok(%i,2,47) + 1),2,47)
}
if (( $gettok(%i,2,47) == 13 )) {
var %i = $puttok(%i,1,2,47)
var %i = $puttok(%i,$calc($gettok($date,3,47) + 1),3,47)
}
return %i
}
alias mdays {
if (( $istok(1 3 5 7 8 10 12,$calc($1),32) )) return 31
if (( $istok(4 6 9 11,$calc($1),32) )) return 30
if (( $calc($1) == 2 )) {
if (( $leapyear($2) )) return 29
if (( !$leapyear($2) )) return 28
}
}
i think the code is nice the way it is. However I would add a Feature for people to be able to display what is in the calendar. I run an online magic the gathering league and i think the calendar is nice for us to input our tourneys we will be running. If you dont mind i would like to make a few edits.
Updated again, now all the days with information written for will have a little asterisk(*) next to the number. I also discovered a spelling mistake in the names of the files, it wrote them as CalenderYEAR instead of CalendarYEAR. I corrected this but all the Calendar files will have to be corrected (in the mIRC directory).
I have changed $leapyear and added a \'Done\' Button. I have also added a function where the current day\'s dialog will appear when mIRC is loaded (The Initialization script warning should be turned off for convenience). The auto-alert option can be turned off from the channel menu. I hope to add an alert system that will tell you your events for the next few days at some point. As for shortening the code, I personally prefer the tabs, but I agree that the code is too long, I have an idea involving creating the tabs but not specifying a tab for the controls, but instead hiding/showing the necessary buttons when a tab is clicked. This way I will only need the 31 buttons but will keep the tabs, I will try to implement this at some point.
As far as determining if it\'s a leapyear, you can use the if-then-else operator // For example: if (4 // %year) return $true
The // operator determines if $v2 is a multiple of $v1. Also I think there would be a more efficient way of displaying the buttons for the days of different months, Such as creating 31 buttons and having them all hidden, then using a drop menu to select a month and then unhiding the correct number of buttons. This would save alot of code in the dialog.