Autor Beitrag
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 19:55 
aber die d,h,s,c werden immer noch nicht ausgegeben.
keine ahnung warum.

mittlerweile sieht der code wie folgt aus:

ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
    ha:=TStringList.Create;
    sha:=TStringList.Create;
    ha.Delimiter:= ' ';
    ha.DelimitedText := Ehand.Text;
    for i := 0 to ha.count-1 do
      begin
        sha.Delimiter:= '.';
        sha.DelimitedText := ha.Strings[i];
        case ord(sha.Strings[i][2]) of
          ord('d'): d:=d+1;
          ord('h'): h:=h+1;
          ord('s'): s:=s+1;
          ord('c'): c:=c+1;
        end;
      end;

    i:=0;
    b:=TStringList.Create;
    b.Delimiter:= ' ';
    b.DelimitedText := Eboard.Text;
    for i := 0 to b.count-1 do
      begin
        sb.Delimiter:= '.';
        sb.DelimitedText := b.Strings[i];
        case ord(sb.Strings[i][2]) of
          ord('d'): d:=d+1;
          ord('h'): h:=h+1;
          ord('s'): s:=s+1;
          ord('c'): c:=c+1;
        end;
      end;

    Ldiamond.caption:='Karo '+IntToStr(d);
    Lheart.caption:='Herz '+IntToStr(h);
    Lpik.caption:='Pik '+IntToStr(s);
    Lclub.caption:='Kreuz '+IntToStr(c);
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:02 
da muss ich doch 2 nehmen damit ich die kartenart ermitteln kann, oder? Was ist die Kartenart Dame[1] oder Pik[2]?

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:04 
pik ist die kartenart
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:08 
Trotzdem 1. Dann müßte es aber
 case ord(sb.Strings[2][1]) of heißen.
Füge mal ein Form.Update; ein oder schau mal im Debugger nach, was er genau macht.

_________________
Markus Kinzler.


Zuletzt bearbeitet von mkinzler am So 24.09.06 20:10, insgesamt 1-mal bearbeitet
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:09 
wa meinst du mit form.update?
einfach unten in die procedure schreiben?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:11 
Zitat:
einfach unten in die procedure schreiben?
Ja, aber schau mal meine korrigierte letzte Antwort an.

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:14 
im aufruf-stack sagt er mir, dass er auf den prozess nicht zugreifen kann.
du meinst [2][eins], oder [L]?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:18 
Ich meine [zwei][eins] weil [eins].. wäre bei d.s 'd'(Als String) und [zwe].. 's'(als String.) durch weiteres Indizieren des Strings bekommst du ein Char, was ein Ordinaltyp ist, und an Position 1 eines Strings steht das erste Zeichen des Strings.

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:20 
das funktioniert auch, wenn das edit so aussieht:
a.h 10.c etc
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:24 
Ich muß mich korrigieren, der StartIndex von StringList.Strings ist ja 0 :oops: und dann ist der [1][1] richtig.

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:25 
hab ich geändert, aber das problem wurde noch nicht behoben.
die ausgabe findet noch nicht statt und der Stack sagt immer noch, dass nicht auf den prozess zugegriffen werden kann.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:28 
Stelle hier mal das gesamte Programm ein. (Als Anhang) ich schau es mir mal an.

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:30 
Da ist das gesamte projekt.
danke für deine hilfe.
Einloggen, um Attachments anzusehen!
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: So 24.09.06 20:46 
1 wäre 'd', 2 wäre '.' und 3 wäre 's'. ich hatte mich nicht genug in den code eingelesen sry :oops:

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 24.09.06 20:48 
wieso ist der . zwei?

ich denke der ist nur das trennzeichen.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 20:59 
Die Signatur der Methode ist falsch es muß so heißen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm5.Berechnen1Click(Sender: TObject);
var
   i:integer;
   d,h,s,c:integer;
   ha,sha,b,sb:TStringList;
begin

Irgendwie stimmt mit dem Projekt was nicht, mein delphi hängst sich beim starten (des Programmes) immer auf.

_________________
Markus Kinzler.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 24.09.06 21:43 
Ich ahbe mal die Form nachgebaut und die Methode folgendermaße implemnetiert:

ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
procedure TForm1.ButtonClick(Sender: TObject);
var
    sl1, sl2: TStrings;
    i, d, h, s, c : Integer;
begin
  d := 0;  h := 0; s := 0; c := 0;
  sl1 := TStringList.Create;
  sl2 := TStringList.Create;
  sl1.Delimiter := ' ';
  sl2.Delimiter := '.';

  sl1.DelimitedText := eHand.Text;
  for i := 0 to sl1.Count - 1 do
  begin
        sl2.DelimitedText := sl1.Strings[i];
        case sl2.Strings[1][1] of
           'd': Inc( d);
           'h': Inc( h);
           's': Inc( s);
           'c': Inc( c);
        end;
  end;

   sl1.DelimitedText := eBoard.Text;
  for i := 0 to sl1.Count - 1 do
  begin
        sl2.DelimitedText := sl1.Strings[i];
        case sl2.Strings[1][1] of
           'd': Inc( d);
           'h': Inc( h);
           's': Inc( s);
           'c': Inc( c);
        end;
  end;
 ...
  sl1.Free;
  sl2.Free;
end;

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mo 25.09.06 16:44 
Danke, aber er gibt die Anzahl noch nicht aus.
Wieso soll er bei der for-schleife sl1.count-1 machen?
Und wieso nur [1][1]?
Das hab ich noch nicht so richtig verstanden.
Was ist wenn ich mehr als eine Karte habe?
z.B. A.h 10.c
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 25.09.06 21:17 
Danke, aber er gibt die Anzahl noch nicht aus.Also bei mir hat er es ausgegeben. Mußt die Ausgabe bei den Punkten (...)einfügen
Zitat:
Wieso soll er bei der for-schleife sl1.count-1 machen?
Weil die Schleife bei 0 beginnt ( Bei 5 elementen geht es dann von 0 bis 4: 0,1,2,3,4 = 5 Elemente)
Zitat:
Und wieso nur [1][1]?
In sl2 sthen ja nur die einzelnen Karten: A.h
In Sl2[1] sthet der 2. Term also h als String in sl2[1][1] steht der h dann als Char.
Zitat:
Was ist wenn ich mehr als eine Karte habe?
z.B. A.h 10.c
Dafür ist ja die for-Schelife

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Di 26.09.06 07:06 
Zitat:

Zitat:
Was ist wenn ich mehr als eine Karte habe?
z.B. A.h 10.c
Dafür ist ja die for-Schelife

Aber was zählt die for schleife genau hoch?
bei dem sl wird ja nichts hochgezählt.