Autor Beitrag
Jenny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: So 04.05.03 15:18 
unit textanalyse;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
Memo2: TMemo;
B_oeffne: TButton;
B_loeschen: TButton;
B_ende: TButton;
L_lines: TLabel;
L_buchst: TLabel;
L_zeichen: TLabel;
L_vok: TLabel;
L_kons: TLabel;
L_sonder: TLabel;
L_leer: TLabel;
L_worte: TLabel;
L_verschieden: TLabel;
L_max: TLabel;
L_mittel: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
OpenDialog1: TOpenDialog;
procedure B_oeffneClick(Sender: TObject);
procedure B_endeClick(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure B_loeschenClick(Sender: TObject);
procedure wortezaehlen ;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1; anzleer, anzlines, anzworte, anzahl, anzsteuer, anzsonder, anzBuchst,anzVok, anzKons: Integer;

const Buchstaben=['A'..'Z',#223,#192..#214,#216..#222,#159];
Vokale= ['A','E','I','O','U'];

implementation

{$R *.DFM}

procedure TForm1.B_oeffneClick(Sender: TObject);
begin
if OpenDialog1.Execute
then begin
Memo1.lines.loadFromFile(OpenDialog1.Filename);
form1.caption:=openDialog1.filename;
end;
end;


procedure TForm1.B_endeClick(Sender: TObject);
begin
close;
end;
Anweisung erwartet aber PROCEDURE gefunden
function kleininGross (C:Char):Char; Zeile zu lang (mehr als 1023 Zeichen :roll:
begin
case ord(c)of
224..246,248..254: kleinInGross:=chr(ord(c)-32);
255:kleiningross:=chr(159);
else
kleinInGross:=UpCase(c)
end;
end;

procedure TForm1.wortezaehlen;
var i,z,anzWorte,w_len,w_max,w,x,y:integer;
ch:char;
txt,wort:string;
worte:TStringList;
a: array[1..50]of integer;
begin //wortezaehlen
anzworte:=0;
w_len:=0;
w_max:=1;
w:=0;
for i:=1 to 50 do a[i]:=0;
worte:=TStringList.Create;//der Variablen Worte wird eine Stringlist zugeführt
worte.sorted:=true;
//B_ende.enabled:=false;
B_loeschen.enabled:=False;
//b_oeffne.enabled:=False;
Application.ProcessMessages;
{Dieser Befehl erlaubt es dem Programm und auch Windows,
Rechenzeit frei zugeben, d.h. ausstehende Nachrichten zu
verarbeiten.}
for z:=0 to Memo1.lines.count-1 do//1.Zeile: 0, letzte: Anzahl-1
begin
txt:=Trim(Memo1.lines[z]); //Trim entfernt Leer- und
//Steuerzeichen am Anfang und Ende
if txt <>'' then
begin
i:=1;
ch:=txt[i];
while i <=length(txt) do
begin
if kleinInGross(ch)in buchstaben
then begin
inc(anzworte);
Wort:='';
while KleinInGross(ch) in buchstaben do
begin
wort:=wort+ch;
inc(i);
ch:=txt[i];
end;
worte.Add(wort);
w_len:=length(wort);
if w_len<=50 then inc (a[w_len])
else inc(a[50]);
w:=w+w_len;
if w_len >w_max then w_max:=w_len;
end //if kleinInGross(ch)
else begin
inc(i);
ch:=txt[i];
end;
end; //while
end; //if txt<>''
Application.Processmessages;
end; //for z:=0...
Memo2.Lines.Assign(worte);
if anzWorte>0
then begin
l_Worte.Caption:=IntToStr(anzWorte);
l_verschieden.caption:=IntToStr(worte.count);
l_max.Caption:=IntToStr(w_max);
l_Mittel.Caption:=IntToStr(Round(w/anzWorte));
for i:=1 to w_max do
memo2.lines.add(IntToStr(i)+' '+IntToStr(a[i]));//+' '+IntToStr((a[i])/anzworte)*100));
b_oeffne.enabled:=True;
b_loeschen.enabled:=True;
b_ende.enabled:=True;
worte.free;//wortliste weg
end; //if anzworte>0
end; //wortezaehlen

procedure TForm1.Memo1Change(Sender: TObject);
var i:Integer;
s,s1:char;
begin
anzahl:=length(memo1.lines.text);
anzvok:=0;
anzkons:=0;
anzleer:=0;
anzBuchst:=0;
anzlines:= memo1.lines.count ;
anzsonder:=0;
anzworte:=0;
for i:=1 to anzahl do
begin
s:=kleinInGross (memo1.text[i]);
if s=#32
then inc (anzleer)else
if s in Buchstaben
then begin inc (anzBuchst);
if s in Vokale
then inc (anzvok)else
inc (anzkons);
end else inc (anzsonder);
end;
{i := 1;
While i< anzahl do
begin
inc(i);
s := kleiningross(memo1.text[i]);
s1 := kleiningross(memo1.text[i-1]);
if (not (s in buchstaben))and
(s1 in buchstaben)then
inc(anzworte);
end; }
L_Worte.caption := inttostr(anzworte);
L_Lines.caption:=intToStr(anzlines);
l_zeichen.caption:=intToStr(anzahl);
l_vok.caption:=intToStr(anzvok);
l_kons.caption:=intToStr(anzkons);
l_buchst.caption:=intToStr(anzbuchst);
l_sonder.caption:=intToStr(anzsonder);
l_leer.caption:=intToStr(anzleer);
wortezaehlen;

end;


procedure TForm1.B_loeschenClick(Sender: TObject);
begin
memo1.clear;
memo2.clear;
form1.caption:='Keine Datei geladen!';
memo1change(sender);
end;

end.


hallo :)

ich hab ein klitzekleines problem bei meiner syntaxprüfung und ich hab keine ahnung wieso das so is weil den text hab ich bloß kopiert :mrgreen: siehe oben in rot :wink:

ich hoffe ihr könnt mir helfen

danke
Jenny

PS.: ich weiss das ich nich zitieren sondern "code" benutzen soll aber da kann man ja nix rot machen :wink:
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: So 04.05.03 16:30 
jeap,
nimm Upcase() , sparst dir ne menge Coding.
Beim Kopieren kann es manchmal vorkommen, dass die IDE von Delphi spinnt. Hab sowas auch schon gehabt. Einfach mal Enter am Zeilenende drücken.

grez.
msch
Jenny Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: So 04.05.03 17:51 
hö? upcase is doch drin? und upcase macht keine sonderzeichen ;)

und das funzt immer noch nich :D ich versteh das nich :roll: mit enter geht das nich... und was hatte upcase überhaupt mit der fehlermeldungszeile zu tun?
Alni
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 205

Win 2000, XP, SuSe, Debian
D5 Prof, D7 Prof, Kylix
BeitragVerfasst: Mo 05.05.03 17:04 
Es scheint wirklich an deiner Delphiversion zu liegen. Ich habs gerade selbst mal ausprobiert mit Copy & Paste und hier bei Delphi 6 Enterprise (Update pack 2) kompiliert er einwandfrei. Vielleicht solltest du dich nach einem Update umschauen für deine Version.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 06.05.03 08:43 
Hi,

kopiere einfach noch mal den Sourcecode aus Deinem Topic oben und füge ihn in die Unit ein. Sollte danach funktionieren!

Das Problem habe ich auch schon öfters gehabt. Meistens öffne ich den Dos-Editor, füge dort den Code ein, kopiere ihn wieder und füge ihn anschließend wieder in Delphi ein. Dann funktioniert es wieder!

Gruß
Tino
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 06.05.03 08:55 
Unbd bitte beim nächsten mal Code-Tags verwenden bei solchen Quellcode-Monstern.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 06.05.03 12:35 
BTW: AnsiUpperCase nimmt auch Sonderzeichen... :roll: ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!