home *** CD-ROM | disk | FTP | other *** search
- {
- .R:E
- }
- program readappoint;
- {$C-}
- type
- string10=string[10];
- string26=string[26];
- string66=string[66];
-
- appoint = record
- yr: byte;
- mo: byte;
- da: byte;
- hr: byte;
- txt: string26;
- end;
- SK2 = record
- yr: byte;
- mo: byte;
- da: byte;
- hr: byte;
- app: string26;
- hour: string10;
- time: real;
- end;
- var
- appointfile,commandline,outplace: string66;
- appfile : file of appoint;
- outfile : text;
- skread: appoint;
- sktmp: sk2;
- skdat: array[1..1000] of sk2;
- i,j,k,noofent,scrnlen: integer;
- m,d,y,todaytest: byte;
- hour: string10;
- today,thisdate,before,after: real;
- noofparam,dm,dy: integer;
- answer: char;
- const
- day:array[0..6] of string10=('Sunday ','Monday ','Tuesday ','Wednesday',
- 'Thursday ','Friday ','Saturday ');
- function days(m,d,y,h: integer):real;
- var
- leap: integer;
-
- const
- diy: array[83..93] of integer=(0,366,731,1096,1461,1827,2192,2557,2922,3288,3653);
- dom: array[1..2] of array[1..12] of integer=((0,31,59,90,120,151,181,212,243,273,304,334),
- (0,31,60,91,121,152,182,213,244,274,305,335));
- begin {function days}
- leap:=1;
- if (1900+y) mod 4 = 0 then leap:=2;
- days:=diy[y]+dom[leap,m]+d+h/40;
- end; {function days}
-
- procedure GetDate(var mo,da,yr:byte);
- type
- regpack = record
- ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
- end;
-
- var
- recpack: regpack; {record for MsDos call}
- month,day: string[2];
- year: string[4];
- dx,cx: integer;
-
- begin {procedure getdate}
- with recpack do
- begin {t}
- ax := $2a shl 8;
- end; {t}
- MsDos(recpack); { call function }
- with recpack do
- begin {t}
- yr:=cx-1900; {convert to string}
- da:=dx mod 256; { " }
- mo:=dx shr 8; { " }
- end; {t}
- end;{procedure getdate}
-
- procedure help;
- begin {procedure help}
- Writeln('Appoint.com v1.11 retrieves appointments from Sidekick''s Appointment Calender');
- writeln('The options are as follows and must be separated by a space:');
- writeln('/F[d:][path]filename.ft the [''s should not appear on the commandline');
- writeln(' the information within [] is optional');
- writeln('/Mnn display an entire months appointments /M5 or /M12');
- writeln('/Bnn display appointments starting nn days before today /B2 is default');
- writeln('/Ann display appointments starting nn days after today /A7 is default');
- Writeln('/Ynn Changes default year to nn as in /y86 /m1 would display appointments');
- writeln(' for january of 1986');
- writeln('/P Route the output to the system printer');
- writeln('/S Sort and rewrite all appointments');
- writeln('/Dmmyy delete all appointments prior to mm/01/yy ');
- writeln(' example appoint /FD:\SKDAT\APPOINT.APP /B3 /A8 /P');
- writeln('use D:\SIDEKICK\APPOINT.APP as the file and output the 3 days before');
- writeln('today and the 8 days after today to the printer');
- end;{procedure help}
- procedure readsk;
- begin
- for i:= 1 to filesize(appfile)-1 do
- begin {1}
- seek(appfile,i);read(appfile,skread);
- with skread do
- begin {2}
- thisdate:=days(mo,da,yr,hr);
- if (length(txt) > 0) and (trunc(thisdate+0.01) <= trunc(after+0.01)) and
- (trunc(thisdate+0.01) >=trunc(before+0.01)) then
- begin {3}
-
- noofent:=noofent+1;
- skdat[noofent].yr:=yr;
- skdat[noofent].mo:=mo;
- skdat[noofent].da:=da;
- skdat[noofent].hr:=hr;
- skdat[noofent].app:=txt;
- skdat[noofent].time:=days(mo,da,yr,hr);
- with skdat[noofent] do
- begin {4}
- if hr=0 then hour:='Title'
- else
- begin {5}
- str(8+ (hr-1) div 2,hour);
- if (hr > 0) and (hr mod 2 = 0) then hour:=hour+':30';
- if hr mod 2 = 1 then hour:=hour+':00';
- end; {5}
- end; {4}
- end; {3}
- end; {2}
- end; {1}
- end; {procedure readsk}
-
- Procedure sortsk;
- begin {procedure sortsk}
- for i :=2 to noofent do
- begin {1}
- for j:= 2 to noofent do
- begin {2}
- if skdat[j].time < skdat[j-1].time then
- begin {t}
- sktmp:=skdat[j-1];
- skdat[j-1]:=skdat[j];
- skdat[j]:=sktmp;
- end; {t}
- end; {2}
- end; {1}
- end; {procedure sortsk}
-
- Procedure outsk;
- begin {procedure outsk}
- for i:=1 to noofent do
- begin {1}
- with skdat[i] do
- begin {2}
-
- if (trunc(time+0.01)=trunc(today+0.01)) and (todaytest=0) then
- begin {t}
- writeln (outfile,'TODAY');
- scrnlen:=scrnlen+1;
- todaytest:=1;
- end; {t}
- if i=1 then
- begin {t}
- writeln(outfile,mo:2,'/',da:2,'/',yr:2,' ',day[(trunc(time+5) mod 7)]:10);
- scrnlen:=scrnlen+1;
- end {t}
- else
- begin {3}
- if trunc(time+0.001) > trunc(skdat[i-1].time+0.001) then
- begin {t}
- writeln(outfile,mo:2,'/',da:2,'/',yr:2,' ',day[(trunc(time+5) mod 7)]:10);
- scrnlen:=scrnlen+1;
- end; {t}
- end; {3}
- writeln(outfile,' ',hour:6,' ',app);
- scrnlen:=scrnlen+1;
- end; {2}
- if (scrnlen>=22) and (outplace='CON:') then
- begin {t}
- write(' please press a key to continue');
- read(kbd,answer);
- writeln;
- scrnlen:=0
- end; {t}
- end; {1}
- if outplace='LST:' then writeln(outfile,chr(12));
- end; {procedure outsk}
-
- begin {program appoint}
- outplace:='CON:';
- noofent:=0;todaytest:=0;scrnlen:=0;
- getdate(m,d,y);
- today:=days(m,d,y,0);
- before:=today-2;after:=today+7;
- appointfile:='D:\SKDAT\APPOINT.DLK';
- noofparam:=paramcount;
- if noofparam = 0 then
- begin {1t}
- help;
- exit;
- end; {1t}
- if noofparam > 0 then
- begin {2}
- for i:=1 to noofparam do
- begin{3}
- commandline:=paramstr(i);
- if upcase(commandline[2])='Y' then
- begin {4t}
- val(copy(commandline,3,length(commandline)),j,k);
- y:=j;
- end; {4t}
- end;{3}
- for i:=1 to noofparam do
- begin {5}
- commandline:=paramstr(i);
- if commandline[1]='/' then
- begin {6}
- case upcase(commandline[2]) of {case}
- 'F' : begin {t}
- appointfile:=copy(commandline,3,length(commandline));
- end; {t}
- 'M' : begin {t}
- val(copy(commandline,3,length(commandline)),j,k);
- before:=days(j,1,y,0);
- after:=days(j+1,1,y,0)-1;
- if j=12 then
- after:=days(1,1,y+1,0)-1;
- end; {t}
- 'B' : begin {t}
- val(copy(commandline,3,length(commandline)),j,k);
- before:=today-j;
- end; {t}
- 'A' : begin {t}
- val(copy(commandline,3,length(commandline)),j,k);
- after:=today+j;
- end; {t}
- 'P' : outplace:='LST:';
- 'D' : begin {1}
- val(copy(commandline,length(commandline)-1,length(commandline)-2),dy,k);
- val(copy(commandline,3,length(commandline)-4),dm,k);
- writeln(days(dm,01,dy,0):8:3);
- write(' delete all data before ',dm:2,'/01/',dy:2,'(n/y) ?');
- answer:='N';
- read(trm,answer);
- if upcase(answer)='Y' then
- begin{2}
- writeln('the data will be deleted');
- before:=days(dm,01,dy,0);
- after:=31000.0;
- assign(appfile,APPOINTFILE);reset(appfile);
-
- readsk;
- sortsk;
- rewrite(appfile);
- with skread do
- begin{3}
- for i:=1 to noofent do
- begin {4}
- yr:=skdat[i].yr;
- mo:=skdat[i].mo;
- da:=skdat[i].da;
- hr:=skdat[i].hr;
- txt:=skdat[i].app;
- seek(appfile,i);
- write(appfile,skread);
- end; {4}
- end; {3}
- exit;
- end;{2}
- writeln('the data will not be deleted');
- end;{1}
- 'S' : begin{1}
- before:=0.0;
- after:=31000.0;
- assign(appfile,APPOINTFILE);reset(appfile);
- readsk;
- sortsk;
- rewrite(appfile);
- with skread do
- begin{3}
- for i:=1 to noofent do
- begin {4}
- yr:=skdat[i].yr;
- mo:=skdat[i].mo;
- da:=skdat[i].da;
- hr:=skdat[i].hr;
- txt:=skdat[i].app;
- seek(appfile,i);
- write(appfile,skread);
- end; {4}
- end; {3}
- exit;
- end;{1}
- 'L' : begin
- end;
- 'E' : begin{1}
- before:=0.0;
- after:=31000.0;
- assign(appfile,APPOINTFILE);reset(appfile);
- readsk;
- sortsk;
- with skread do
- begin{3}
- i:=1;
- writeln('number of appointments is ',noofent);
- for j:=1 to 2 do
- begin
- yr:=skdat[i].yr;
- mo:=skdat[i].mo;
- da:=skdat[i].da;
- hr:=skdat[i].hr;
- txt:=skdat[i].app;
- i:=noofent;
- writeln(mo:2,'/',da:2,'/',yr:2,' ',txt);
- end;
- end; {3}
- exit;
- end;{1}
-
- end; {case}
- end; {6}
- end; {5}
- end; {2}
- assign(outfile,outplace);
- assign(appfile,APPOINTFILE);reset(appfile);
- readsk;
- sortsk;
- outsk;
- close(appfile);
- end. {program appoint}
-