{------------------------------------------------------------------}
{- Procedure FormCreate -}
{- -}
{------------------------------------------------------------------} procedure TMainForm1.FormCreate(Sender: TObject); var S: String;i:integer; begin
Opt.ProgramDir := SysUtils.GetCurrentDir()+ '\';
DoMakeSound := true; // set Title
Application.Title := AppName+' '+Version+' '+SubVersion; //language processing //ForeignLocale;
getLanguages; //init last thread
LastSoundThread := nil;
LastVoiceThread := nil;
LastMorseThread := nil; // for SQ passord etc.
Crypt := LowerCase(AppName);
Passw := MidStr(LowerCase(AppName),2,3);
SQ.ParamsLoaded := false; //produce events
crlf[0] := chr(13);
crlf[1] := chr(10);
crlf[2] := chr(0); //disable onchange;
PPn:= FontName.OnChange;FontName.OnChange:=nil;
PPs:= FontSize.OnChange;FontSize.OnChange:=nil; //edit boxes follow here
GetFontNames; //end set options if LowerCase(ExtractFileName(Application.ExeName))<> ObjectFile then
Abort; //Application.OnIdle:= MyIdleHandler;
Application.OnMinimize := StartTimer;
EventFound := False;
WinEvent := false;
Utilities.SpVoice := nil; // initialization for i:= 1 to 2 do Blank2[i] := ' '; for i:= 1 to 4 do Blank4[i] := ' '; for i:= 1 to 28 do Blank28[i] := ' '; for i:= 1 to 32 do Blank32[i] := ' '; for i:= 1 to 36 do Blank36[i] := ' '; for i:= 1 to 120 do Blank120[i] := ' '; //builtin gimmicks
Current(ThisTime); //
LangsDir := readl;
LastSearchText := '';
LastMousePosIn := false;
LastMouseTime := Now; //
Slept:=0; //create timer
Timer1.Enabled := True;
Timer1.Interval := Opt.Waittime*1000;
Timer1.OnTimer := MyTimeHandler; // get acoustical voices
Utilities.EnumVoices(Opt.Voice,D_Leise[Opt.lang],VoiceBox); //
OpenDialog.InitialDir := ExtractFilePath(Opt.programDir);
SaveDialog.InitialDir := OpenDialog.InitialDir; // ----- here is getOptions --------------------
getoptions; //set voice index
VoiceBox.ItemIndex := Opt.Voice;
Utilities.Speaker := Opt.Voice; //command line parameters // close on too many invocations if ParamCount > 0 thenbegin
s := LowerCase(ParamStr(1)); if (Opt.LastRun = Now) and (S = 'auto') then
Close; end; // set Mouse Pos
LastMousePos := Mouse.CursorPos; // set last run
Opt.LastRun := Now; //position and size
MainForm1.Position := Opt.winpos;
MainForm1.Top := Opt.Top;
MainForm1.Left := opt.Left;
MainForm1.Width := Opt.width;
MainForm1.Height := Opt.height; // file selector if Opt.EditCommon then RemoteMark := CommonEvent else RemoteMark := LocalEvent;
ShouldPutEvents := false; end;
{------------------------------------------------------------------}
{- Procedure FormPaint -}
{- -}
{------------------------------------------------------------------} procedure TMainForm1.FormPaint(Sender: TObject); var ts, so:TSound; begin
Ereignisse.ReadOnly := false;
Netzwerk.Checked := Opt.EditCommon;
Verzeichnis.Checked := Opt.CommonDir<>'';
Voice1.Visible := Opt.Voice>0;
Sound1.Visible := false; for so:=HappyBirthDay to DingDong do if (Opt.SoundFile[so]>' ') then
Sound1.Visible:= true; for ts:=HappyBirthDay to Sailing do
SoundPlayed[ts] := false;
VoiceSpoken := false; //now branch from visibility if Tokens.Visible thenbegin
Tokens.TitleCaptions[0] := D_Lexem[Opt.lang];
Tokens.TitleCaptions[1] := D_Wertinakt[Opt.lang]; endelseif ListView1.Visible thenbegin endelseif ereignisse.Visible thenbegin
Ereignisse.Clear; if LastSoundThread <> nilthenbegin
LastSoundThread.Terminate;
LastSoundThread:=nil; end;
Slept:=0; // delete and create new timer if Timer1 <> nilthenbegin
timer1.Destroy;
timer1 := TTimer.Create(Mainform1); end;
Timer1.Enabled := True;
Timer1.Interval := Opt.Waittime*1000;
Timer1.OnTimer := MyTimeHandler;
Ereignisse.DefAttributes.Color := opt.FontColor;
Ereignisse.DefAttributes.name := opt.Fontname;
Ereignisse.DefAttributes.size := opt.FontSize;
Ereignisse.DefAttributes.Style := opt.FontStyles;
Greetings; ifnot (SplashForm = nil) thenbegin
SplashForm.Destroy;
SplashForm := nil end;
AllCount := 0;
GetAllEvents; //get list of items
FillList; // Set Edit-Dialog with Eventfile //Clipboard.Clear;
DoMakeSound := false; end;
Ereignisse.ReadOnly:=true; end;
{------------------------------------------------------------------}
{- Procedure PutAllEvents -}
{- local and remote -}
{------------------------------------------------------------------} Procedure TMainForm1.PutAllEvents; begin if Opt.EditCommon then PutEvents(Opt.CommonDir+EreignisDatei,CommonEvent);
PutEvents(Opt.LocalDir+EreignisDatei,LocalEvent); end;
{------------------------------------------------------------------}
{- Procedure GetAllEvents -}
{- local and remote -}
{------------------------------------------------------------------} Procedure TMainForm1.GetAllEvents; var i:integer; begin ifnot DirectoryExists(Opt.LocalDir) thenbegin// nur Initialisierung
DefaultOptions;
PutOptions; end; for i:=1 to 32 do EventTypes[i] := '';
AllCount:=0;
GetEvents(Opt.LocalDir+EreignisDatei,LocalEvent); if Opt.CommonDir<>''thenbegin if Fileexists(Opt.CommonDir+EreignisDatei) then
GetEvents(Opt.CommonDir+EreignisDatei,CommonEvent); end end;
{------------------------------------------------------------------}
{- Procedure DefaultOptions -}
{- set Options -}
{------------------------------------------------------------------} Procedure TMainForm1.DefaultOptions; begin //hidden sounds
Opt.lang := 1; if syslocale.fareast then Opt.locale := 'fareast'; if syslocale.MiddleEast then Opt.locale := 'middleeast';
Opt.SoundFile[Kennenlerntag] := 'Arc-enciel.wav';
Opt.SoundFile[MartinasGeburtstag] := 'ChargeCavalerie.wav';
Opt.SoundFile[Hochzeitstag] := 'Anyone.wav';
Opt.SoundFile[BeethovensGeburtstag] := 'Fur Elise.mid';
Opt.SoundFile[BachsGeburtstag] := 'Bach Joy.mp3';
Opt.alarmzeit := 7;
Opt.Fontname := MainForm1.Font.Name;
Opt.FontStyles := [];
Opt.FontSize := MainForm1.Font.Size;
Opt.width := 400;
Opt.height := 300;
Opt.winpos := poScreenCenter;
opt.top := Screen.Height div 5;
Opt.Left := Screen.Width div 5;
Opt.Voice := 0;
Opt.VoiceRate := 1;
Opt.WarnMe := true;
Opt.Waittime := 45; // time until close of program
Opt.WakeTime := 10; // time of day, when program starts
Opt.LastRun := Yesterday;
Opt.Vorname := '';
Opt.Name := '';
Opt.Email := '';
opt.inited := 'J';
Opt.EditCommon := false;
Opt.CommonDir := '';
Opt.PlayMorseCodes := false;
GetAgendaDirectories; end;{DefaultOpt.s}
{------------------------------------------------------------------}
{- Procedure getOpt.s -}
{- set Opt.s -}
{------------------------------------------------------------------} Procedure TMainForm1.GetOptions; var fn:String;fc:FileName; begin
Fn:=Opt.ProgramDir+OptionsDatei; if FileExists(Fn) thenbegin
AssignFile (Opts,Fn); try
Reset(Opts); finally end; ifNot Eof(Opts) thenbegin try
Read(Opts,Opt);
CloseFile(Opts) except
DefaultOptions; end; endelsebegin
StrPCopy(fc,fn);
DeleteFile(fc);
Opt.inited:=' '; end; end else
DefaultOptions; //initialize from options if Opt.inited <> 'J'then DefaultOptions; end;{GetOpt.s}
{------------------------------------------------------------------}
{- Procedure PutOpt.s -}
{- store Opt.s -}
{------------------------------------------------------------------} Procedure TMainForm1.PutOptions; var Fn:String; begin
Fn:=Opt.ProgramDir+OptionsDatei;
DeleteFile(PChar(Fn));
Opt.inited := 'J';
Opt.winpos := MainForm1.Position;
opt.Top := MainForm1.Top;
opt.Left := MainForm1.Left;
Opt.width := MainForm1.Width;
Opt.height := MainForm1.Height;
AssignFile(Opts,Fn); try
Rewrite(Opts); if IOResult = 0 then begin
write(Opts,Opt);
CloseFile(Opts); end; finally end; end;{Opt.s}
{------------------------------------------------------------------}
{- Procedure Current Time -}
{- forto fetch system time -}
{------------------------------------------------------------------} Procedure TMainForm1.Current(var Setting : Date); var Ti : TDateTime;
S : Variant; begin
Ti := Now; With Setting do begin
Minute := MinuteOfTheHour(Ti);
Hour := HourOfTheDay(Ti);
Day := DayOfTheMonth(Ti);
WeekDay := DayOfTheWeek(Ti);
Month := MonthOf(Ti);
Year := YearOf(Ti); end;
s := Ti; end; {Current}
{------------------------------------------------------------------}
{ Thread Communicator }
{ work in parallel }
{ forto sound a result or so }
{------------------------------------------------------------------} Procedure TMainForm1.Communicator(Tx:String); var
TH: TMyMorseThread; begin if Opt.PlayMorseCodes thenbegin if (LastMorseThread=nil) thenbegin
TH := TMyMorseThread.Create(true);
TH.OnTerminate:=ThreadsDone;
TH.this:=1;
TH.id := TH.ThreadID;
TH.Tx[TH.this] := Tx;
TH.Priority := tpLower;
TH.Resume; // 1. resume = beginn, sonst = weitermachen end// stoppen mit suspend elsebegin
TH := LastMorseThread;
TH.Suspend;
TH.this := (TH.this + 1) mod 12;
TH.Tx[TH.this] := Tx;
TH.Resume end end; end;
{------------------------------------------------------------------}
{ Thread Sounder }
{ work in parallel }
{ forto sound a result or so }
{------------------------------------------------------------------} procedure TMainForm1.Sound1Click(Sender: TObject); begin if Opt.Voice>0 then
Opt.Voice:=0;
Sound1.Visible:=Opt.Voice>0; end;
Procedure TMainForm1.Sounder(so : TSound); var
TH: TMySoundThread; begin if DoMakeSound andNot SoundPlayed[so] thenbegin if LastSoundThread= nilthenbegin
TH := TMySoundThread.Create(true);
TH.OnTerminate:=ThreadsDone;
LastSoundThread := TH;
TH.ptr:=1; TH.this:=1;
StrPCopy(TH.sf[TH.ptr],Opt.SoundFile[so]);
TH.id := TH.ThreadID;
TH.so := so;
TH.Priority := tpLower;
TH.Resume; // 1. resume = beginn, sonst = weitermachen end// stoppen mit suspend elsebegin
TH := LastSoundThread;
TH.Suspend;
TH.ptr := (TH.ptr + 1) mod 12;
StrPCopy(TH.sf[TH.ptr],Opt.SoundFile[so]);
TH.Resume end end;
SoundPlayed[so] := true; end; {Sounder}
procedure TMainForm1.Speech(SText: String); begin ifnot LastMousePosIn then
Utilities.Speak(Opt.Voicerate,SText);
VoiceSpoken := true; end; {Sounder}
{------------------------------------------------------------------}
{- Procedure DayofYear -}
{- forto find the number of a Day -}
{------------------------------------------------------------------} Function TMainForm1.DayofYear(AnyTime:Date) : integer; Var
Sum : 0 .. 366; begin
Sum := 0; if AnyTime.Month > 1 then
Sum := Sum + 31; if AnyTime.Month > 2 then begin
Sum := Sum + 28; if AnyTime.Year mod 4 = 0 then
Sum := Sum + 1; if AnyTime.Year mod 100 = 0 then
Sum := Sum - 1; end; if AnyTime.Month > 3 then
Sum := Sum + 31; if AnyTime.Month > 4 then
Sum := Sum + 30; if AnyTime.Month > 5 then
Sum := Sum + 31; if AnyTime.Month > 6 then
Sum := Sum + 30; if AnyTime.Month > 7 then
Sum := Sum + 31; if AnyTime.Month > 8 then
Sum := Sum + 31; if AnyTime.Month > 9 then
Sum := Sum + 30; if AnyTime.Month > 10 then
Sum := Sum + 31; if AnyTime.Month > 11 then
Sum := Sum + 30;
Sum := Sum + AnyTime.Day;
DayofYear := Sum end;{DayofYear}
{------------------------------------------------------------------}
{- Procedure Convert -}
{- forto Convert the input record -}
{------------------------------------------------------------------} Procedure TMainForm1.Convert(A : TAppoint;var b : Date); var i : integer; begin
b := ThisTime; if a.Month[1]=' 'then a.Month[1]:='0'; if a.Month[2]=' 'then a.Month[2]:='0'; if a.Day[1]=' 'then a.Day[1]:='0'; if a.Day[2]=' 'then a.Day[2]:='0'; if a.Year[1]=' 'then a.Year[1]:='0'; if a.Year[2]=' 'then a.Year[2]:='0'; if a.Year[3]=' 'then a.Year[3]:='0'; if a.Year[4]=' 'then a.Year[4]:='0'; if (a.Month[1] in ['0','1']) and (a.Month[2] in ['0' .. '9']) and (a.Day[1] in ['0' .. '3']) and (a.Day[2] in ['0' .. '9']) and (a.Year[1] in [' ','0','1','2']) and (a.Year[2] in [' ','0' .. '9']) and (a.Year[3] in [' ','0' .. '9']) and (a.Year[4] in [' ','0' .. '9']) then begin
i:= (ord(A.Month[1])-ord('0'))*10+ord(a.Month[2])-ord('0');
b.Month := i;
i:= (ord(A.Day[1])-ord('0'))*10+ord(a.Day[2])-ord('0');
b.Day := i;
i := (ord(a.Year[1]) - ord('0'))*1000
+(ord(a.Year[2]) - ord('0'))*100
+(ord(a.Year[3]) - ord('0'))*10
+(ord(a.Year[4]) - ord('0'));
b.Year := i end else begin
b.Month := ThisTime.Month - 1;
b.Day := ThisTime.Day end; end;{Convert}
{------------------------------------------------------------------}
{- Procedure Inspect -}
{- forto search for'UND' -}
{------------------------------------------------------------------} Function TMainForm1.Inspect(s:string) : boolean; var Su : string;
Sl : string; begin
sl := LowerCase(s);
su := LowerCase(D_UND[Opt.lang]);
inspect := Pos(' '+Su+' ',Sl) > 0 end;{Inspect}
{------------------------------------------------------------------}
{- Procedure Event -}
{- forto announce Events -}
{------------------------------------------------------------------} function Similar(S1,S2:String):boolean; var i:integer; Se, Se1, Se2 : setofchar; tt:boolean; begin
S1:=Lowercase(Trim(S1));
S2:=Lowercase(Trim(S2));
tt := S1 = S2; ifnot tt thenbegin
Se1 := []; for i:=1 to Length(S1) do
Se1 := Se1 + [S1[i]];
tt:= true; for i:=1 to Length(S2) do
tt := tt and (S2[i] in Se1); ifnot tt thenbegin
Se2 := []; for i:=1 to Length(S2) do
Se2 := Se2 + [S2[i]];
Se := Se2 - Se1;
Se := Se - [' ','.',';',':'];
tt := Se = []; end end;
Similar := tt end;
{------------------------------------------------------------------}
{- Procedure Event -}
{- forto announce Events -}
{------------------------------------------------------------------} procedure TMainForm1.SendNote(Who :Char36;YearNum:integer;Typ:Char32;Email:Char36;Ind:integer); var Tex, St, U:String; Num:String;From, ToId, Von:String;Gw:String;Y:Integer; begin
From:=Trim(Opt.Email); if From <>''thenbegin
ToId:=Trim(Email); if ToId <> ''thenbegin if YearNum>0 then Num:=Inttostr(Yearnum)+'.'else Num:='';
Von:=' von '+Opt.Vorname+' '+Opt.name; if Opt.Name=''then Von:=''; if From<>''thenbegin
GW := Application.Title+'-'+D_Glueckwunsch[Opt.lang];
Tex:=D_Herzlichen[Opt.lang]+' '+D_Glueckwunsch[Opt.lang]+' '+
D_zum[Opt.lang]+' '+Num+' '+Trim(Typ)+Von+'!';
U:=Uppercase(MidStr(Tex,1,1));
Tex:=U+MidStr(TEx,2,Length(TEx)); if All[Ind].Done[3] in ['0' .. '9']then TryStrToInt(All[Ind].Done,Y) else Y:=0;; if Y < YearNum thenbegin
St:=SendMail(SMTP,Opt.SMTPHost,Opt.SMTPUser,Opt.SMTPPassword,
From,ToId, GW, Tex); if St=''thenbegin
Y:=YearNum;
All[Ind].Done[1]:=chr(ord('0')+Y div 1000);Y:=Y -(Y div 1000)*1000;
All[Ind].Done[2]:=chr(ord('0')+Y div 100); Y:=Y -(Y div 100)*100;
All[Ind].Done[3]:=chr(ord('0')+Y div 10); Y:=Y -(Y div 10)*10;
All[Ind].Done[4]:=chr(ord('0')+Y); end else
ShowMessage(St); end; end; end end; end;
{------------------------------------------------------------------}
{- Procedure Event -}
{- forto announce Events -}
{------------------------------------------------------------------} procedure TMainForm1.Event(Ind:integer;Diff : integer); Var
Who :Char36;
Typ:Char32;
Wish:Char36;
Month:Char2;
Day:Char2;
Year:Char4;
BC:Char;
Email:Char36;
Plural, DoUnderline, VeryImportant : boolean;
YearNum : integer;
Subject, Predicate, Events, Temporal, Additional, Sentence : String;
st,sl,sw,swl,l : integer; Sim : boolean; begin
Who:=All[Ind].Who;
Typ:=All[Ind].Typ;
Wish:=All[Ind].Wish;
Month:=All[Ind].Month;
Day:=All[Ind].Day;
Year:=All[Ind].Year;
BC:=All[Ind].BC;
Email:=All[Ind].Email;
EventFound := true;
LastWho := Who;
l:=1; while l<=nolanguages dobegin if similar(Trim(Typ),D_Geburtstag[l]) thenbegin
StrCopy(@Typ,PChar(D_Geburtstag[opt.lang]));l:=langmax+1;end elseif similar(Trim(Typ),D_Hochzeitstag[l]) thenbegin
StrCopy(@Typ,PChar(D_Hochzeitstag[opt.lang]));l:=langmax+1;end elseif similar(Trim(Typ),D_Namenstag[l]) thenbegin
StrCopy(@Typ,PChar(D_Namenstag[opt.lang]));l:=langmax+1;end elseif similar(Trim(Typ),D_Jubilaeum[l]) thenbegin
StrCopy(@Typ,PChar(D_Jubilaeum[opt.lang]));l:=langmax+1;end;
l:=l+1 end;
DoUnderline := false;
VeryImportant := false;
Subject := Trim(Who);
Plural := Inspect(Trim(Who));
YearNum := StrToInt(StringReplace(Year,' ', '0',[rfReplaceAll ])); if (BC=' ') or (BC='') then
YearNum := ThisTime.Year - YearNum else
YearNum := ThisTime.Year + YearNum; if YearNum = 1 then
Events := StringReplace(Events,'%a', D_Ersten[Opt.lang],[rfReplaceAll ]) elseif YearNum = 2 then
Events := StringReplace(Events,'%a', D_Zweiten[Opt.lang],[rfReplaceAll ]) elseif YearNum = 3 then
Events := StringReplace(Events,'%a', D_Dritten[Opt.lang],[rfReplaceAll ]) elsebegin if (Year = '0000') or (Year = ' ') or (YearNum = 0) thenbegin
Events := StringReplace(Events,'%a', '',[rfReplaceAll ]) endelsebegin
Events := D_40th[Opt.lang];
VeryImportant:=Yearnum mod 10 = 0;
Events := StringReplace(Events,'%a', inttostr(YearNum),[rfReplaceAll ]) end end; if (Year[1] <> ' ') and (Year[4] <> ' ') then Events := Events + ' ' + Trim(Typ) else Events := Trim(Typ); if Diff > 0 then begin if Plural then Predicate := D_werdenhaben[Opt.lang] else Predicate := D_wirdhaben[Opt.lang]; if Diff = 1 thenbegin
Temporal := D_MORGEN[Opt.lang];
Sounder(DingDong) end elsebegin
Temporal := StringReplace(D_In[Opt.lang],'%t',inttostr(abs(Diff)),[rfReplaceAll ]);
Sounder(Ding) end; end; // Birthday or Similar if Diff = 0 thenbegin if Plural then Predicate := D_HABEN[Opt.lang] else Predicate := D_HAT[Opt.lang];
Temporal := D_Heute[Opt.lang];
Sim := false; for l := 1 to langmax do
Sim := Sim or Similar(Trim(Typ),D_Geburtstag[l]);
SendNote(Who,YearNum,Typ,EMail,Ind); if Sim thenbegin
DoUnderline := true;
Sounder(HappyBirthday) endelse
Sounder(SongofJoy); end; if Diff < 0 thenbegin if Plural then Predicate := D_Hatten[Opt.lang] else Predicate := D_Hatte[Opt.lang]; if abs(Diff) = 1 then Temporal := D_Gestern[Opt.lang] else Temporal := StringReplace(D_vor[Opt.lang],'%t',inttostr(abs(Diff)),[rfReplaceAll ]); end;
Additional := ''; if (Trim(Wish) > ' ') thenbegin
additional := additional +' '+Trim(Wish) end;
Sentence := D_Syntax[Opt.lang];
Sentence := StringReplace(Sentence,'%s',Subject,[rfReplaceAll ]);
Sentence := StringReplace(Sentence,'%p',Predicate,[rfReplaceAll ]);
Sentence := StringReplace(Sentence,'%e',Events,[rfReplaceAll ]);
Sentence := StringReplace(Sentence,'%t',Temporal,[rfReplaceAll ]);
Sentence := StringReplace(Sentence,'%a',Additional,[rfReplaceAll ]); if (All[Ind].Done[3] in ['0' .. '9']) or (All[Ind].Done[2] in ['0' .. '9'])then
Sentence:=Sentence+'(@)';
Sentence := Sentence + '.';
Sentence[1] := UpCase(Sentence[1]);
Speech(Sentence);
Communicator(Sentence); //mark beginnings
st := Length(ereignisse.Lines.GetText);
sl := Length(Sentence);
sw := Pos(Subject,Sentence) - 1;
swl := Length(Subject); //copy to editor
Clipboard.AsText := Sentence;
Ereignisse.PasteFromClipboard;
ereignisse.SelStart := st;
ereignisse.SelLength := sl;
Ereignisse.SelAttributes.Color := clBlack; if DoUnderline then
Ereignisse.SelAttributes.Style := Ereignisse.SelAttributes.Style + [fsUnderline]; if VeryImportant then
Ereignisse.SelAttributes.Size := Ereignisse.SelAttributes.Size + 2 else
Ereignisse.SelAttributes.Size := Opt.FontSize;
ereignisse.SelStart := st+sw;
ereignisse.SelLength := swl;
Ereignisse.SelAttributes.Color := clGreen;
ereignisse.SelStart := st+sl;
Clipboard.AsText := crlf;
Ereignisse.PasteFromClipboard;
Ereignisse.SelAttributes.Style := opt.FontStyles; end;{Event}
{------------------------------------------------------------------}
{- Procedure GetEvents -}
{- forto look up Events -}
{------------------------------------------------------------------} Procedure TMainForm1.GetEvents(Datei:String;Remote:Char2); Type
TRecord = record casebooleanof
true : (a : LAppoint);
false: (c: record
b : TAppoint; end); end; Var
Trec : TRecord;
Diff : integer;
Goal : Date;
YearDays : integer;
S : String;Errors:boolean; procedure addeventtype; var i,n:integer;found:boolean; begin
i:=1;found := false;n:=1; while ((i<=32) and (not found)) dobegin if eventtypes[i]=''thenbegin n := i; found := true end;
i:=i+1; end;
found:=false; for i:=1 to n do if EventTypes[i]=All[AllCount].Typ then
found := true; ifnot found and (n<32) thenbegin
EventTypes[n] := all[allcount].typ; end end; begin
EventFound := false; Errors:=false; if FileExists(Datei) thenbegin
AssignFile(Events,Datei); try
Reset(Events); finally end; if IOResult = 0 then begin
TRec.c.b.Month := Blank2;
TRec.c.b.Day := Blank2;
TRec.c.b.Year := Blank4;
TREc.c.b.Typ := Blank32;
TRec.c.b.Who := Blank36;
TRec.c.b.Wish := Blank36;
TRec.c.b.Picture := Blank120;
TRec.c.b.Remote := Blank2;
TRec.c.b.Done := Blank4;
TRec.c.b.Repeats := Blank28;
TRec.c.b.Email := Blank36; whilenot Eof(Events) andnot Errors do begin try
Readln(Events,TRec.a); finally if TRec.c.b.repeats[1]<>' 'then
ShouldPutEvents:=true; end;
Convert(TRec.c.b,Goal);
AllCount := AllCount + 1; if Allcount > AllCountMax thenbegin
S := D_OutofMem[Opt.lang] +' >'
+InttoStr(AllcountMax)+ ' '+D_Ereignis[Opt.lang];
ShowMessage(S);Errors:=true; end;
All[AllCount] := TRec.c.b;
All[AllCount].Remote := Remote;
AddeventType;
Goal.Year := ThisTime.Year;
YearDays := 365; if (ThisTime.Year mod 4 = 0) andnot (ThisTime.Year mod 100 = 0) then
YearDays := 366;
Diff := DayofYear(Goal)-DayofYear(ThisTime); if abs(Diff) > YearDays-opt.alarmzeit-1 then
Diff := abs(Diff) - YearDays; if abs(Diff) <= opt.alarmzeit then
Event(AllCount, Diff);
TRec.c.b.Month := Blank2;
TRec.c.b.Day := Blank2;
TRec.c.b.Year := Blank4;
TREc.c.b.Typ := Blank32;
TRec.c.b.Who := Blank36;
TRec.c.b.Wish := Blank36;
TRec.c.b.Picture := Blank120;
TRec.c.b.Remote := Blank2;
TRec.c.b.Done := Blank4;
TRec.c.b.Repeats := Blank28;
TRec.c.b.Email := Blank36;
TRec.c.b.Remote := Remote; end;
CloseFile(Events) end; end; if (AllCount=0) or (IOResult<>0) thenbegin // make at least one event
AllCount := 1;
All[1].Month := '05';
All[1].Day := '01';
All[1].Year := '1949';
strpcopy(@All[1].Typ,D_Firstof[Opt.lang]);
strpcopy(@All[1].Who,D_Everyone[Opt.lang]);
strpcopy(@All[1].Wish,D_WantsFree[Opt.lang]);
All[1].Picture := '';
All[1].Remote := RemoteMark;
PutAllEvents; end; end;{GetEvents}
{------------------------------------------------------------------}
{- Procedure PutEvents -}
{- save Events -}
{------------------------------------------------------------------} Procedure TMainForm1.PutEvents(Datei:String; RM:Char2); const eoln=chr(13)+chr(10); type pmem=^mem;
mem=array[0..512] ofchar; Var
i,j,k:integer;
S:String;pch:pmem;
Eout:Textfile; begin if Fileexists(Datei) then DeleteFile(PChar(Datei));
AssignFile (Eout,Datei); try
Rewrite(Eout); for i:=1 to Allcount dobegin if All[i].Remote = RM thenbegin
S:='';
Pch:=@All[i];k:=sizeof(All[i])-1; for j:=0 to k do begin
Write(Eout,Pch^[j]); end;
Writeln(Eout); end end;
CloseFile(Eout); finally end; end;{PutEvents}
{------------------------------------------------------------------}
{- Procedure Fill List -}
{- fill ListView from All -}
{------------------------------------------------------------------} Procedure TMainForm1.FillList; var
I: Integer;
ListItem: TListItem; begin with ListView1 do begin
Parent := Self;
Align := alClient;
ViewStyle := vsReport;
{------------------------------------------------------------------}
{- GetLanguages -}
{------------------------------------------------------------------} procedure TMainForm1.IOLanguages; var
S,St : String;
lnr, current,m,d,ind,lind : integer; procedure Check(var S:String); begin try if Langsdir=readl thenbegin
readln(Langs,S);
S:=Trim(S); end else
writeln(Langs,S); finally end; if (IOResult >= 0) and (S > '') thenbegin
lnr :=lnr+1;
Str(lnr,St); if (Langsdir=readl) andnot ((Pos('<',S)>0) and (Pos('>',S)>0)) then raise EFileInvalid.Create(St+D_Incorrect[Opt.lang]+S) end else raise EFileInvalid.Create(St+D_Incorrect[Opt.lang]+S); end ;
procedure RWs(var S:String); var T:String;C:Char; begin if Langsdir=writel thenbegin
T:=Tokens.Keys[ind];
C:=T[Length(T)]; if C='>'then
T:=T+'.'+inttostr(lind);
S:=Tokens.Cells[1,ind]; end;
Check(T); try If Langsdir=readl then readln(Langs,S) else writeln(Langs,S); finally end;
S:=Trim(S); if (IOResult >= 0) thenbegin
lnr :=lnr + 1;
St := S;
Str(lnr,St); if Pos('<',S) > 0 then raise EFileInvalid.Create(St+D_Incorrect[Opt.lang]+S); // insert to value editor if (Langsdir=readl) then
Tokens.InsertRow(T,S,true);
ind := ind+1;
lind:=lind+1; end; end ; begin
ind:=1;lind:=0;
Tokens.TitleCaptions[0]:=D_Lexem[Opt.lang];
Tokens.TitleCaptions[1]:=D_Wertinakt[Opt.lang];
AssignFile (Langs,Opt.ProgramDir+SprachDatei); try if LangsDir=readl then
Reset(Langs) elsebegin
Rewrite(Langs); end; finally end;
lnr:= 1;
S:=inttostr(nolanguages);
RWs(S);
TryStrToInt(S,nolanguages); if nolanguages > langmax then raise EFileInvalid.Create(D_TooMany[Opt.lang]); for current := 1 to nolanguages do begin
lind := 1;
RWs(D_Langs[current]);
RWs(D_Foreign[current]);
RWs(D_DFormats[current]);
RWs(D_Syntax[current]);
RWs(D_40th[current]); for m:=1 to 12 dobegin if langsdir=writel then S := D_Months[current,m] else s:='';
RWs(S); if langsdir=readl then
D_Months[current,m] := S; end; for d:=0 to 6 dobegin if langsdir=writel then S := D_Days[current,d] else s:='';
RWs(S); if langsdir=readl then
D_Days[current,d] := S; end;
RWs(D_Geburtstagskalender[current]);
RWs(D_GutenMorgen[current]);
RWs(D_GutenAbend[current]);
RWs(D_GutenTag[current]);
RWs(D_Jetztist[current]);
RWs(D_Und[current]);
RWs(D_Hat[current]);
RWs(D_Haben[current]);
RWs(D_Hatte[current]);
RWs(D_Hatten[current]);
RWs(D_wirdhaben[current]);
RWs(D_werdenhaben[current]);
RWs(D_Gestern[current]);
RWs(D_Heute[current]);
RWs(D_Morgen[current]);
RWs(D_In[current]);
RWs(D_Vor[current]);
RWs(D_Ereignis[current]);
RWs(D_Geburtstag[current]);
RWs(D_Hochzeitstag[current]);
RWs(D_Namenstag[current]);
RWs(D_Jubilaeum[current]);
RWs(D_Ersten[current]);
RWs(D_Zweiten[current]);
RWs(D_Dritten[current]);
RWs(D_Ist[current]);
RWs(D_Erste[current]);
RWs(D_Zweite[current]);
RWs(D_Dritte[current]);
RWs(D_Ein[current]);
RWs(D_Uhr[current]);
RWs(D_Stehtan[current]);
RWs(D_Wirklich[current]);
RWs(D_Geaendert[current]);
RWs(D_Status[current]);
RWs(D_Neu[current]);
RWs(D_Aendern[current]);
RWs(D_Sichern[current]);
RWs(D_Loeschen[current]);
RWs(D_Exportieren[current]);
RWs(D_Importieren[current]);
RWs(D_Drucken[current]);
RWs(D_Ende[current]);
RWs(D_Optionen[current]);
RWs(D_Sprache[current]);
RWs(D_Alarmzeit[current]);
RWs(D_Font[current]);
RWs(D_Hilfe[current]);
RWs(D_Ueber[current]);
RWs(D_Wunschzeit[current]);
RWs(D_Wunschsprache[current]);
RWs(D_Wuenschtsich[current]);
RWs(D_Wuenschensich[current]);
RWs(D_Am[current]);
RWs(D_OK[current]);
RWs(D_Finde[current]);
RWs(D_Abbrechen[current]);
RWs(D_Einfuegen[current]);
RWs(D_setzeSprecher[current]);
RWs(D_leise[current]);
RWs(D_Sprecher[current]);
RWs(D_Sprachausgabe[current]);
RWs(D_Klaenge[current]);
RWs(D_setzeFett[current]);
RWs(D_setzeSchrift[current]);
RWs(D_setzeGroesse[current]);
RWs(D_setzeItalic[current]);
RWs(D_setzeUnterstrichen[current]);
RWs(D_aendereEreignis[current]);
RWs(D_Ereignissedrucken[current]);
RWs(D_loescheEreignis[current]);
RWs(D_neuesEreignis[current]);
RWs(D_setzeSprache[current]);
RWs(D_Warum[current]);
RWs(D_ListEdit[current]);
RWs(D_LangEdit[current]);
RWs(D_Lexem[current]);
RWs(D_Wertinakt[current]);
RWs(D_Month[current]);
RWs(D_Day[current]);
RWs(D_Year[current]);
RWs(D_Who[current]);
RWs(D_Typ[current]);
RWs(D_Wish[current]);
RWs(D_Picture[current]);
RWs(D_Select[current]);
RWs(D_Emaileingeben[current]);
RWs(D_PrintHead[current]);
RWs(D_OutofMem[current]);
RWs(D_Firstof[current]);
RWs(D_Everyone[current]);
RWs(D_WantsFree[current]);
RWs(D_Incorrect[current]);
RWs(D_TooMany[current]);
RWs(S);strpcopy(@D_NotImpl[current],S);
RWs(S);strpcopy(@D_Parameter[current],S);
RWs(D_SoundFiles[current]);
RWs(D_SprachTexte[current]);
RWs(D_EndeZeit[current]);
RWs(D_Warnemich[current]);
RWs(D_Geschwindigkeit[current]);
RWs(D_SprecherTest[current]);
RWs(D_UhrzeitStart[current]);
RWs(D_Spende[current]);
RWs(D_SehrGut[current]);
RWs(D_Gut[current]);
RWs(D_Befriedigend[current]);
RWs(D_Ausreichend[current]);
RWs(D_Schlecht[current]);
RWs(D_SehrSchlecht[current]);
RWs(D_Name[current]);
RWs(D_Vorname[current]);
RWs(D_Urteil[current]);
RWs(D_Kommentar[current]);
RWs(D_Senden[current]);
RWs(D_Abbruch[current]);
RWs(D_Email[current]);
RWs(D_NoInternet[current]);
RWs(D_Lizenz[current]);
RWs(D_Herzlichen[current]);
RWs(D_Glueckwunsch[current]);
RWs(D_von[current]);
RWs(D_zum[current]);
RWs(D_Netzwerk[current]);
RWs(D_Verzeichnis[current]);
RWs(D_Uebertragen[current]);
RWs(D_Server[current]);
RWs(D_User[current]);
RWs(D_Passwort[current]);
RWs(D_Feedback[current]);
RWs(D_Postamt[current]);
RWs(D_SendeMorse[current]);
RWs(D_Filler4[current]);
RWs(D_Filler5[current]);
RWs(D_Filler6[current]);
RWs(D_Filler7[current]);
RWs(D_Filler8[current]);
RWs(D_Filler9[current]);
RWs(D_Filler10[current]);
RWs(D_Filler11[current]); end; if (LangsDir=readl) andnot eof(Langs) then raise EFileInvalid.Create(D_Incorrect[Opt.lang]) ;
CloseFile(Langs); end;
{------------------------------------------------------------------}
{- Delphi generated procedures -}
{------------------------------------------------------------------} function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
FontType: Integer; Data: Pointer): Integer; stdcall; begin
TStrings(Data).Add(LogFont.lfFaceName);
Result := 1; end;
procedure TMainForm1.GetFontNames; var
DC: HDC; begin
DC := GetDC(0);
EnumFonts(DC, nil, @EnumFontsProc, Pointer(FontName.Items));
ReleaseDC(0, DC); end;
{ Event Handlers }
procedure TMainForm1.ForeignLocale; const
ENGLISH = (SUBLANG_ENGLISH_US shl 10) or LANG_ENGLISH;
GERMAN = (SUBLANG_GERMAN shl 10) or LANG_GERMAN;
FRENCH = (SUBLANG_FRENCH shl 10) or LANG_FRENCH;
SPANISH = (SUBLANG_SPANISH shl 10) or LANG_SPANISH;
ITALIAN = (SUBLANG_ITALIAN shl 10) or LANG_ITALIAN;
PORTUGAIS = 1046; begin if Opt.lang = 0 then case SysLocale.DefaultLCID of
SPANISH: Opt.lang := 5;
ENGLISH: Opt.lang := 2;
FRENCH: Opt.lang := 3;
GERMAN: Opt.lang := 2;
ITALIAN: Opt.lang := 4;
PORTUGAIS: Opt.lang := 6; else Opt.lang := 1; end;
GetFormatSettings; if D_Foreign[opt.lang] = 'fareast'then SysLocale.FarEast := true; if D_Foreign[opt.lang] = 'middleeast'then SysLocale.MiddleEast := true; if Screen.Imes.Count>0 then Ereignisse.ImeName := Screen.Imes[0]; end;
procedure TMainForm1.NetzwerkClick(Sender: TObject); begin
Opt.EditCommon := not Opt.EditCommon;
Netzwerk.Checked := Opt.EditCommon; if Opt.EditCommon and (Opt.CommonDir='') then Verzeichnis1Click(Sender); if Opt.EditCommon then RemoteMark := CommonEvent else RemoteMark := LocalEvent; end;
Procedure TMainForm1.GetAgendaDirectories; var Drive:String; begin
Opt.LocalDir := GetEnvironmentVariable('Userprofile')+ '\' + AppName + '\'; ifnot DirectoryExists(ExtractFileDir(Opt.LocalDir)) then ifnot CreateDir(ExtractFileDir(Opt.LocalDir)) thenbegin
showmessage('Cannot create Home Directory');
ExitProcess(55) end; ifNot DirectoryExists(Opt.LocalDir) thenbegin
Opt.LocalDir := GetEnvironmentVariable('Homedir')+ '\'; end; ifnot DirectoryExists(ExtractFileDir(Opt.LocalDir)) then ifnot CreateDir(ExtractFileDir(Opt.LocalDir)) thenbegin
showmessage('Cannot create Home Directory');
ExitProcess(55) end; ifNot DirectoryExists(Opt.LocalDir) thenbegin
Opt.LocalDir := 'C:' + '\'; end; ifnot DirectoryExists(ExtractFileDir(Opt.LocalDir)) then ifnot CreateDir(ExtractFileDir(Opt.LocalDir)) thenbegin
showmessage('Cannot create Home Directory');
ExitProcess(55) end; // compatibility with old version
Drive := ExtractFileDrive(Opt.ProgramDir); case GetDriveType(PChar(Drive)) of { une valeur positive indique un lecteur correct }
DRIVE_REMOVABLE: opt.EditCommon:=true;
DRIVE_FIXED: ;
DRIVE_CDROM: ;
DRIVE_RAMDISK: ;
DRIVE_REMOTE: opt.EditCommon:=true; end;
Opt.CommonDir := ''; end;
function move(var a:arrayofchar):String; var i,m:integer;
S:String; begin
m := length(a)-1;
S:=''; for i:=0 to m do
S := S + a[i];
move := S end;
procedure TMainForm1.PrintEventFile(Sender: TObject); var
i:integer; procedure Insert; begin
ereignisse.SelStart := ereignisse.SelStart+length(Clipboard.AsText);
ereignisse.PasteFromClipboard;
ereignisse.SelStart := ereignisse.SelStart;
Ereignisse.SelLength := Length(Clipboard.AsText); end; begin if PrintDialog.Execute thenbegin
Clipboard.Clear;
Ereignisse.Clear;
Ereignisse.SelAttributes.Name := 'FixedSys';
Ereignisse.DefAttributes.Name := 'FixedSys';
Ereignisse.SelAttributes.Color := Opt.FontColor;
Ereignisse.SelAttributes.Style := opt.FontStyles;
Clipboard.AsText := D_PrintHead[Opt.lang]+Crlf;
Insert;
Clipboard.AsText := '----------------------------------------------'
+'----------------------------------------------'
+'------------------- '+Crlf;
Insert; for i:=1 to AllCount do begin
Clipboard.AsText := All[i].Month+'/'+All[i].Day+' ';
Insert;
Clipboard.AsText := All[i].Year+' ';
insert;
Ereignisse.DefAttributes.Color := clGreen;
Clipboard.AsText := All[i].Who;
insert;
Ereignisse.DefAttributes.Color := clBlack;
Clipboard.AsText := All[i].Typ+' '+All[i].Wish+crlf;
insert; end;
Ereignisse.Print(D_Stehtan[Opt.lang]);
Ereignisse.Clear;
Clipboard.Clear;
FormPaint(Sender); end end;
procedure TMainForm1.FileExit(Sender: TObject); begin
Close; end;
procedure TMainForm1.EditUndo(Sender: TObject); begin with Ereignisse do if HandleAllocated then SendMessage(Handle, EM_UNDO, 0, 0); end;
procedure TMainForm1.EditCut(Sender: TObject); begin
Ereignisse.CutToClipboard; end;
procedure TMainForm1.EditCopy(Sender: TObject); begin
Ereignisse.CopyToClipboard; end;
procedure TMainForm1.EditPaste(Sender: TObject); begin
Ereignisse.PasteFromClipboard; end;
procedure TMainForm1.FontChange(Sender: TObject); begin
tokens.Visible := false;
ListView1.Visible := false;
Ereignisse.Visible := true; if (Sender=FontSize) thenbegin // Name and Size of Font // Achtung: Fehler in Delphi 7 ????? if strtoint(Fontsize.text) <> opt.FontSize thenbegin if Fontsize.Text > '0'thenbegin
opt.FontSize := strtoint(FontSize.Text);
ereignisse.DefAttributes.Size := strtoint(fontsize.Text) end; end end elseif sender=fontname thenbegin
Ereignisse.DefAttributes.Name := FontName.Items[FontName.ItemIndex];
Opt.Fontname := FontName.Items[FontName.ItemIndex]; end elsebegin if UnderlineButton.Down then Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style + [fsUnderline] else Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style - [fsUnderline]; if BoldButton.Down then Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style + [fsBold] else Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style - [fsBold]; if ItalicButton.Down then Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style + [fsItalic] else Ereignisse.DefAttributes.Style := Ereignisse.DefAttributes.Style - [fsItalic];
Opt.fontStyles := ereignisse.DefAttributes.Style; end; end;
procedure TMainForm1.LanguageChange(Sender: TObject); var i:integer; begin for i:=1 to nolanguages do if LanguageBox.Items [LanguageBox.ItemIndex] = D_Langs[i] then
Opt.lang := i;
MenuLanguageChange(Sender);
Repaint;
Opt.lang := LanguageBox.ItemIndex +1;
FormPaint(Sender); end;
procedure TMainForm1.MenuLanguageChange(Sender: TObject); begin
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.