Autor Beitrag
ex4ct
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Fr 09.06.06 23:19 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Timer1Timer(Sender: TObject);
var
i:Integer;
 begin
 for i:=0 to Memo1.Lines.count-1 do
  if 'google' =Memo1.Lines[i] then begin
   showmessage('google');
  end;
end;


Mit diesem Code will ich den Textfeld Memo1 nach dem Wort "google" durchsuchen und wenn sie da ist soll showmessage('google'); kommen. Bin langsam am Verzweifeln, denn das Wort "google" wird nur erkannt wenn sie an erster Stelle steht z.B. so:

->
Das ist ein Text
google
das ist ein text
<-

Aber wenn sie so steht klappt es nicht

->
Das ist ein Text google
texT
Textgoogle
<-

Das Wort "google" soll auch erkannt werden wenn sie mit einem anderen Wort oder Zeichen zusammengeschrieben ist z.B. Wortgoogle,google!

Ich währe sehr sehr dankbar wenn mir einer helfen würde.
Danke schon im Vorraus!!


Moderiert von user profile iconraziel: Topic aus Internet / Netzwerk verschoben am So 11.06.2006 um 09:19
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Fr 09.06.06 23:26 
Ein klassisches Thema für die Forensuche :les:
Ich hab nach Suche in: Delphi-Forum, Delphi-Library SUCHEN RICHEDIT gesucht und z.B. folgendes gefunden:
www.delphi-forum.de/...ight=suchen+richedit

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Fr 09.06.06 23:26 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure googlesuchen;
Var i:integer;
s:string;
begin
 s:=Memo1.text;
 for i:=1 to length(s) do
 begin
  if (s[i]='g') and (s[i+1]='o') and (s[i+2]='o') and (s[i+3]='g') and (s[i+4]='l') and (s[i+5]='e') then
  begin
   Showmassage('google');
   exit;
  end;
 end;
end;

das ist zwar nicht das schnellste aber es führt einfach und Verständlich zum Ziel

EDIT: else entfernt


Zuletzt bearbeitet von DelphiAnfänger am Sa 10.06.06 13:12, insgesamt 1-mal bearbeitet
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.06.06 23:33 
warum nicht mit Pos()?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Timer1Timer(Sender: TObject);  
var  
i:Integer;  
 begin  
 for i:=0 to Memo1.Lines.count-1 do  
  if Pos('google',Memo1.Lines[i]) <> 0 then begin  
   showmessage('google');  
  end;  
end;


warum machst du das in der timer prozedur? das leuchtet mir nicht ganz ein? wenn der intervall zu klein ist muss man das prog doch über den taskmanger beenden weil man nicht mit schließen der message nach kommt

EDIT:

warn komma zu viel...
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 09.06.06 23:43 
ausblenden Delphi-Quelltext
1:
if Pos('google', LowerCase(Memo1.Lines.Text)) <> 0 Then ShowMessage('Google!');					

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Fr 09.06.06 23:48 
in meiner delphi hilfe steht:
"Die Groß/Kleinschreibung wird von Pos nicht berücksichtigt."
heißt das nich das es egal ist obs groß oder klein geschrieben wird? aber habs probiert der macht da wirklich nen unterschied