1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| function Assistant: string; var PO: String; ini: TIniFile; begin PO:=ExtractFilePath(Application.Exename); ini:=TIniFile.Create(PO+'Data\assistant.ini'); Assistant:=ini.readstring('Assistant','Name','Assistant'); ini.free; end;
function You: string; var PO: String; ini: TIniFile; begin PO:=ExtractFilePath(Application.Exename); ini:=TIniFile.Create(PO+'Data\assistant.ini'); You:=ini.readstring('Owner','Name','???'); ini.free; end;
function Such(wort: string): integer; var Zeile : integer; begin Zeile := SendMessage(Form1.RichEdit1.Handle, EM_LINEFROMCHAR, Form1.RichEdit1.SelStart, 0); Such := Form1.RichEdit1.FindText(wort, SendMessage(Form1.RichEdit1.Handle, EM_LINEINDEX, Zeile, 0), Form1.RichEdit1.SelStart, [stMatchCase]); end;
procedure TForm1.Abfrage(); var Zeile, Spalte, nam: integer; begin Zeile := SendMessage(richedit1.Handle, EM_LINEFROMCHAR, richedit1.SelStart, 0); Spalte := richedit1.SelStart - SendMessage(richedit1.Handle, EM_LINEINDEX, Zeile, 0); if Spalte = 0 then begin PostMessage(Richedit1.Handle,WM_KEYDOWN,VK_LEFT,0); PostMessage(Richedit1.Handle,WM_KEYDOWN,VK_LEFT,0); end; nam := RichEdit1.FindText(You, SendMessage(richedit1.Handle, EM_LINEINDEX, Zeile, 0), RichEdit1.SelStart, [stMatchCase]); if (nam) and (such('hallo ')) <> -1 then RichEdit1.Lines.Add(Assistant + ': Hi.') else if (nam) and (such('hi ')) <> -1 then RichEdit1.Lines.Add(Assistant + ': Hi.') else if (nam) and (such('moin ')) <> -1 then RichEdit1.Lines.Add(Assistant + ': Hi.') else if (nam) <> -1 then RichEdit1.Lines.Add(Assistant + ': Das verstehe ich nicht.'); end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key=VK_RETURN) and (Edit1.Text <> '') then begin RichEdit1.Lines.Add(You + ': ' + Edit1.Text); Edit1.Text := ''; end; end; |