Autor Beitrag
DaVinciFF7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:14 
Hallihallo.
Ich soll als Hausaufgabe in Informatik ein Programm modifizieren, sodass man in eine Memobox einen Text eingeben kann und dieser dann in 3er Stücke zerhackt wird und die Tripel in einen Suchbaum einsortiert werden. Das sieht bei mir momentan so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure zerstueckeln;
var i:integer;
begin
if i<length(form1.memo1.Text) then
form1.eingabe.text:=form1.memo1.text(i to i+2);
i:=i+1;
eingabebtnclick;
zerstueckeln;
else
end;


eingabe ist ein Editfeld, wo man normalerweise Begriffe eingibt, die dann, sobald man auf den btn klickt, in den Suchbaum einsortiert werden. Deshalb auch der Prozeduraufruf "eingabebtnclick".
Er hat nur irgendwie ein Problem mit der Stelle "form1.eingabe.text:=form1.memo1.text(i to i+2)"
Es kommt immer die Fehlermeldung "missing operator or semicolon".
Wie kann ich den denn dazu bringen, dass er in das Editfeld die Buchstaben von i bis i+2 aus dem Memofeldtext einsetzt?
Dankeschön im Vorraus :)

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 21:20 
Hi,

schau Dir dazu mal die Funktion Copy an.
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:22 
Mit copy hab ichs auch schon probiert, das müsste dann ja so aussehen:

ausblenden Delphi-Quelltext
1:
form1.eingabe:=copy(form1.memo1.text,i to i+2);					


oder nicht?

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 21:27 
Schau Dir die Hilfe zu Copy mal genau an ;-)
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 29.09.08 21:28 
user profile iconDaVinciFF7 hat folgendes geschrieben:
Mit copy hab ichs auch schon probiert, das müsste dann ja so aussehen:

form1.eingabe:=copy(form1.memo1.text,i to i+2);

oder nicht?

Das Schlüsselwort to findet nur bei der For-Schleife Verwendung! :zwinker:
Copy erwartet zudem drei Parameter, den Ursprungstext, die Startpostion und die Länge des zu kopierenden Stückes.

Grüße,
Marc.
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:30 
Ok dankeschön, ich versuchs nochmal :)


Zuletzt bearbeitet von DaVinciFF7 am Mo 29.09.08 21:35, insgesamt 2-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 29.09.08 21:32 
Um genau zu sein: to gibts nur bei einer for-Schleife.
// EDIT:
Wie schnell doch die Zeit vom Aufruf der Seite bis zur Antwort vergeht...
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 21:33 
user profile iconjaenicke hat folgendes geschrieben:
Um genau zu sein: to gibts nur bei einer for-Schleife.


Schrieb Marc zwei Beiträge weiter oben auch :zwinker:

[edit]Jetzt editiert er auch noch :P[/edit]
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:36 
Ok an dem Copy meckert er nicht mehr rum, habe jetzt aber ein weiteres Problem.

Ich will nämlich die Prozedur "eingabebtnclick" aufrufen, aber er sagt dann

"undeclared identifier: 'eingabebtnclick'"

Wenn ich noch ein Tform1. davorsetze kommt

"not enough actual parameters"

Was muss ich tun, damit er einfach diese Prozedur startet?
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 21:38 
Versuch mal:

ausblenden Delphi-Quelltext
1:
eingabebtnclick(Self);					
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:50 
Da kommt die Fehlermeldung

"undeclared identifier 'self'"
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 21:56 
Das war jetzt auch nur total ins Blinde geraten.

Wie schaut denn die Prozedur bzw. der Prozedurenkopf aus?
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 21:58 
Die Prozedur eingabebtnclick sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.EingabeBtnClick(Sender: TObject);
begin
   if Eingabe.text<>'' then Baum.einfuegen(Baum, Eingabe.text);
   Eingabe.clear;  ActiveControl:=Eingabe;
end;

ich hab auch schon probiert, (sender: TObject); dahinter zu setzen, aber dann sagt er "undeclared identifier 'sender'"

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 22:00 
Entweder Du machst nun Deine Prozedur zerstueckeln zu einer Methode der Form oder Du rufst EingabeBtnClick(nil); auf.
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 22:03 
Was genau meinst du? oO
Wie soll ich denn die Prozedur zu einer Methode machen?
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 29.09.08 22:08 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure Blubb;
begin
  ShowMessage('Hallo Welt');
end;

So ist das eine Prozedur.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
type TFormBla = class(TForm)
  private
    procedure Blubb;
  ...
end;
...
procedure TFormBla.Blubb;
begin
  ShowMessage('Hallo Welt');
end;

So ist das eine Methode von TFormBla.
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 22:09 
Du machst aus dem:

ausblenden Delphi-Quelltext
1:
procedure zerstueckeln;					


das hier:

ausblenden Delphi-Quelltext
1:
procedure TForm1.zerstueckeln;					


Und der Rest hat ja Detlef (ab ins Bett!) geschrieben :P
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 29.09.08 22:10 
*Hehe* :mrgreen:
DaVinciFF7 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32

Win XP
Delphi 2007
BeitragVerfasst: Mo 29.09.08 22:13 
Nja da hat sich immernoch nichts geändert ^^
Die Muhkuh
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 33



BeitragVerfasst: Mo 29.09.08 22:14 
Zeig am besten mal Deinen gesamten Code. Wenn Du es richtig umgesetzt hast, sollte es funktionieren.

Delphi-Tags nicht vergessen.