%externalroutine padan(%string (255) s) %externalroutinespec define(%string (255) s) %externalintegerfnspec stoi(%string (255) s) %string (255) t,u,v,s2,t2 %integer i,j,k,x,crash %owninteger this day, hours, thours %owninteger max = 0, fhours, hours up %real mtbf %recordformat padf(%string (15) name, %integer last crash,crash,lastt,maxu, %c first,last) %ownrecord (padf) %array pada(1:100) %ownrecord (padf) %name pad %string (255)%array res(1:12) %owninteger no of res %conststring (3) %array day(1:7) = "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" %conststring (12) %array month(1:12) = "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" %ownintegerarray nodays(1:12) = 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 %on %event 9 %start -> finish %finish %integerfn constr(%string (255) s) %integer i,j,n %cycle; %exit %unless charno(s,1)=' ';s->(" ").s;%repeat %cycle; %exit %unless charno(s,length(s))=' ';length(s)=length(s)-1;%repeat %result = stoi(s) %end %routine read line(%string (255)%name s) %integer i, j s=""; j=0 %cycle readsymbol(i); %return %if i = 10 j = j+1 s=s.tostring(i) %unless j>130 %repeat %end %cycle i = 2, 1, 12; nodays(i) = nodays(i)+nodays(i-1); %repeat %unless s->s.("/").t %start printstring("/ Please ") %stop %finish define("1,".s); define("2,".t) select input(1) %cycle readline(s) %if charno(s,1)='(' %then %exit %repeat %cycle readline(s) %if charno(s,1)='(' %or charno(s,1)='_' %then %continue %if s->("From").t %or s->("Via").t %or %c s->(" PAD").t %or s->("To:").s %or %c s->("Msg").t %or s="" %or s->("cant").t %then %continue %unless s->t.(" ").u %then t=s %and u="" %cycle i = 1, 1, 7 %if t=day(i) %start; ! got a date etc %unless u -> t.(" ").s %then %monitor %cycle j = 1, 1, 12 %if t = month(j) %start; ! got a month %cycle; %exit %unless charno(s,1)=' '; s->(" ").s; %repeat %unless s -> s2.(" ").t2 %then %monitor %cycle; %exit %unless s2->(" ").s2; %repeat this day = nodays(j)+stoi(s2) thours = hours hours = this day*24 %if fhours = 0 %then fhours=hours; ! base line printstring("Hours ="); write(hours, 5); space; printstring(s2) space;printstring(t);newline -> got date %finish %repeat %monitor %finish %repeat ! should be a pad name %if max = 0 %then -> empty %cycle i = 1, 1, max pad == pada(i) %if pad_name = t %start; ! got a match ok: %cycle no of res = 1, 1, 11 %unless u -> s2.("|").u %then %exit res(no of res) = s2 %repeat res(no of res) = u %if no of res < 10 %then -> got date; ! not enough info s=res(10); %unless s->s2.(":").t2.(":").t %then -> got date %cycle; %exit %unless s2->(" ").s2;%repeat hours up = stoi(s2) %if hours-pad_lastt > hours up %start %if pad_first = 0 %then pad_first=hours %else %c pad_crash = pad_crash+1 pad_last crash = hours-hours up printstring(pad_name); write(hours up, 5); newline %finish pad_lastt = hours s=res(4); ! max conns x = constr(s) %if x>pad_maxu %then pad_maxu = x -> got date %finish %repeat empty: max = max+1 %if max = 101 %start %cycle j = 1, 1, 100; write(j, 3); printstring(" ".pada(j)_name." ") %repeat %stop %finish pad == pada(max); pad_name=t;->ok got date: %repeat finish: select output(2) printstring("Got "); write(max, 1); printstring(" entries") printstring(" Base:"); write(fhours, 5); printstring(" Current:") write(hours, 5) printstring(", Total Hours covered ="); write(hours-fhours, 5) printstring(" Pad Name No. Crashes MTBF Max Cons Last Crash ") %cycle i = 1, 1, max pad == pada(i) printstring(pad_name); spaces(15-length(pad_name)) %if pad_crash=0 %then crash=1 %else crash=pad_crash mtbf = (pad_first-pad_lastt)/(crash) j=pad_lastt-pad_last crash %if j > mtbf %then mtbf = j write(pad_crash, 5); spaces(8); print(mtbf, 5, 0) %if pad_crash=0 %then printstring(" +") %else spaces(2) spaces(8); write(pad_maxu, 5) spaces(8); write(pad_last crash, 5) newline %repeat %end %endofprogram