Autor Beitrag
bruce185
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 14:15 
hallo,
ich mach mir grad ein WordMix Spiel, und wenn ich die zahlen eingebe, dann soll die wörter so darstellen wie ich sie der reihenfolge eingegeben habe, beispiel:

user defined image

oder so:

user defined image

man kann das doch irgendwie mit Strings machen, oder?
könnt ihr mir vieleicht zeigen wie man sowas macht?

Danke euch schonmal für die Hilfe :wink:

Gruss Andreas
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mi 16.08.06 14:19 
user profile iconbruce185 hat folgendes geschrieben:

man kann das doch irgendwie mit Strings machen, oder?


Kann man...

user profile iconbruce185 hat folgendes geschrieben:
könnt ihr mir vieleicht zeigen wie man sowas macht?

Könnten wir auch... machen wir aber nicht...
Wir geben dir höchstens Hilfestellung, selbst die Lösung zu finden...

Schau dir beispielsweise mal TStringlist an (hier suchen oder in der Online Hilfe von Delphi)...

Und wenn dann konkrete Fragen auftauchen, dann sehen wir weiter ;-)
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 14:24 
ja toll,
ich weiss net wie man das mit TStringList macht, und was bringt mir die hilfe von Delphi?
da wird nur erklärt was das ist und wie man es einsetzt, aber net wie man mit Zahlen die wörter einfügen kann -.-
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mi 16.08.06 14:27 
Großartig!
Deine Bereitschaft, selbst was zu tun, strahlt einem ja förmlich entgegen!
Zu Stringlisten findest du allein hier im Forum mehrere hundert Beiträge mit Beispielen etc., da ist mit Sicherheit was dabei, was du brauchen kannst... und wie du selbst schon gesagt hast, in der Delphi Hilfe steht, wie man sie einsetzt. Man muss da nur noch ein wenig lesen und denken können. Wo bitteschön ist also das Problem?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.08.06 14:30 
Du fügst die Wörter in der ursprünglichen Reihenfolge in die StringList ein und dann gibts du über den Index das jeweilige Wort aus.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.08.06 18:24 
Na woran haperts denn genau? Finde erstmal heraus wie man einen String einer Stringlist hinzufügen kann und wie man anhand eines Index einen bestimmten String auslesen kann.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 19:07 
sry, ich weis zwar wie man eine StringListe erzeugt, aber dann weiss ich nicht weiter -.-

@Marco D. könntest du mir vieleicht ein beispiel Posten wie das geht?
ich wäre dir sehr dankbar dafür.

Gruss Andreas
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.08.06 19:22 
Du fügst nacheinander alle Wörter des Satzes in eine StringList ein und gibts dann anhand der Zahl das jeweilige Wort aus:
ausblenden Delphi-Quelltext
1:
memo1.lines[memo1.lines.itemindex] := memo1.lines[memo1.lines.itemindex] + List.Items[zahl+1];					

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 19:31 
ich danke dir,
aber ich will die RichEdit komponent nehmen, und da geht des net mit RichEdit1.Lines.ItemIndex
wieso?

edit: ich habs jetzt mal so gemacht:

ausblenden Delphi-Quelltext
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:
var
  Form1: TForm1;
  List: TStringList;
  Index: Integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  List := TStringList.Create;
  try
    List.Add('wieder');
    List.Add('bin');
    List.Add('kaum');
    List.Add('schon');
    List.Add('müde!');
    List.Add('ich,');
    List.Add('erwacht,');
    List.Add('So');
  finally
    List.Free;
  end;
end;


ist es so richtig?

Gruss Andreas
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 20:22 
ok, des funktioniert schon einigermaßen, aber wie kann ich rausfinden welche zahlen alles in Edit1.Text stehen, und das die wörter dann so da stehen, habs schonmal so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  List := TStringList.Create;
  try
    List.Add('wieder ');
    List.Add('bin ');
    List.Add('kaum ');
    List.Add('schon ');
    List.Add('müde! ');
    List.Add('ich, ');
    List.Add('erwacht, ');
    List.Add('So ');
    Memo1.Lines.Add(List[Zahl]);
  finally
    List.Free;
  end;


jetzt brauche ich doch eine while schleife, oder if abfrage?
wenn ich in edit1: 24031 eingebe, dann sollen die wörter so in der reihenfolge auftauchen.

Danke schonmal!

Gruss Andreas
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.08.06 20:33 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var i: integer;

for i := 1 to Length(edit1.text) do
   Richedit1.Lines.Add(List.Strings[strtoint(edit1.text[i])]);

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Mi 16.08.06 20:37, insgesamt 1-mal bearbeitet
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 16.08.06 20:34 
for schleife sollte dienste tun und dann über strtoint(bla[]) auf die einzelnen zahlen zu greifen, kA ob der char als string akzeptiert sollte aber eigentlich gehen
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 20:38 
coool, danke dir, kann man des so anstellen das es net untereinander gesachrieben wird, sondern in einer Zeile, ohne das des vorherige in RichEdit gelöscht wird was da noch drin steht?

MFG Andreas
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 16.08.06 20:40 
kann man, ich weiß aber net, was daran jetzt das problem ist ? du weißt doch sicherlich, wie man strings aneinanderkettet ?

ausblenden Delphi-Quelltext
1:
astr := 'Horst' + ', ' + 'Walter';					
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 16.08.06 20:43 
Ist die Frage, wie man beim RIchEdit auf die aktuelle Zeile zugreift, um sie mit dem Wort zu verknüpfen, da es kein ItemIndex gibt.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 20:53 
ich meine dass das Wort in einer Zeile ausgegeben wird.
das müsste gehen, ich weiss nur net wie.

@F34r0fTh3D4rk klar weiss ich das, aber ich mache das anders mit zahlen die mit der for schleife ausgelesen wird :wink:

edit: kann man des net irgendwie so machen:
ausblenden Delphi-Quelltext
1:
memo1.Text := memo1.Text + memo1.Lines.Add(List.Strings[strtoint(edit1.text[i])]);					

?
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mi 16.08.06 21:15 
ok, ich hab es so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
for i := 1 to Length(edit1.text) do
  RichEdit1.Text := RichEdit1.Text + List.Strings[strtoint(edit1.text[i])];
  RichEdit1.Lines.Add('');


und vielen dank für eure hilfe :D

Gruss Andreas