#!/bin/csh # Timetabler for Bradford University Computer Science second year... # (A bit dodgy 'cos this year's timetable is all over the place!) set subject = ( "0.0_L_a-FREE" "0.0_L_LUNCH" "0.3_B_C&D-Sys." \ "0.13_L_C&D-Sys." "0.13_L_Data-Comms." "0.28_T_Data-Comms." \ "0.16_L_DSA-III" "0.17_L_DSA-III" "0.13_L_Func.Prog." ) # 1 FREE ??? 0.0 # 2 LUNCH ??? 0.0 # 3 C&DS lab 0.3 # 4 C&DS lec 0.13 # 5 Data.Comms. lec 0.13 # 6 Data.Comms. tut 0.28 # 7 DSA III lec 0.16 # 8 DSA III lec 0.17 # 9 Func.Prog. lec 0.13 set mon = ( 1 1 1 1 2 1 1 1) set tue = ( 1 7 4 1 2 1 8 3) set wed = ( 1 7 4 1 2 1 1 1) set thu = ( 1 9 9 3 2 1 1 3) set fri = ( 6 6 1 5 2 1 1 1) if ($#argv == 0) then set day = `date +%a` @ hour = `date +%H` @ minute = `date +%M` goto main endif if ($#argv != 2) then echo "Usage: `basename $0` [day hour]" exit 1 endif @ len = `expr $1 : '.*'` if ($len != "3") then echo "Day should be 3 letters long." exit 1 endif set num = `echo $2| sed -n 's/[0-9][0-9]/\.\./p'` if ($num != ".." || $2 < 0 || $2 > 23 ) then echo "Hour should be a number in range 00-23 (2 digits)." exit 1 endif set day = $1 @ hour = $2 @ minute = 0 main: @ hour-= 8 @ next = ( $hour + 1 ) @ to_go = ( 60 - $minute ) if ($next == "24") @ next = 0 set now = "" set nex = "" @ edge = 0 if ($hour < 1 || $hour > 8) goto null if ($next > 8 ) then @ next = 8 @ edge = 1 endif if ($day == "Mon") then set now = $subject[$mon[$hour]] set nex = $subject[$mon[$next]] endif if ($day == "Tue") then set now = $subject[$tue[$hour]] set nex = $subject[$tue[$next]] endif if ($day == "Wed") then set now = $subject[$wed[$hour]] set nex = $subject[$wed[$next]] endif if ($day == "Thu") then set now = $subject[$thu[$hour]] set nex = $subject[$thu[$next]] endif if ($day == "Fri") then set now = $subject[$fri[$hour]] set nex = $subject[$fri[$next]] endif null: if ($now == "") then set now = "0.0_L_Nothing" set nex = "0.0_L_Nothing" endif if ($edge == 1) then set nex = "0.0_L_Nothing" endif set now = `echo $now|sed -n 's/_/ /gp'` set nex = `echo $nex|sed -n 's/_/ /gp'` if ($#argv == 0) then date endif if ($now[2] == "L") set now[2] = "lecture" if ($now[2] == "T") set now[2] = "tutorial" if ($now[2] == "B") set now[2] = "lab" if ($now[1] == "0.0") then echo "It is $now[3] now." else echo "You should be in a $now[3] $now[2] in room $now[1] now. It is $minute minutes into the $now[2]." endif if ($nex[2] == "L") set nex[2] = "lecture" if ($nex[2] == "T") set nex[2] = "tutorial" if ($nex[2] == "B") set nex[2] = "lab" if ($nex[1] == "0.0") then echo "There is $nex[3] next." else echo "You have a $nex[3] $nex[2] in room $nex[1] next. There are $to_go minutes to go." endif