Autor Beitrag
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 31.03.15 20:01 
wie das jetzt so richtig weiter geht kann ich mir noch nicht so ganz vorstellen, aber ich muss als erstes jetzt irgendwie die mengen geburt und ueberleben aus der unit2 in die unit1 bekommen glaub ich.

ja, also ich hab das einfach so gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm2.btnEndeClick(Sender: TObject);
begin
  close;
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 31.03.15 20:51 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
ja, also ich hab das einfach so gemacht:
Top. :zustimm:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
ich muss als erstes jetzt irgendwie die mengen geburt und ueberleben aus der unit2 in die unit1 bekommen glaub ich.
Die Mengen-Variablen sollten ja eigentlich bereits in der Form1-Klasse deklariert sein, so gesehen sind die schon da, wo sie hingehören. :lupe: Was du jetzt brauchst, ist der Zugriff auf Komponenten in Form2 von einer Methode in Form1. :idea: Und das geht so:
ausblenden Delphi-Quelltext
1:
if Form2.ckgeburt0.Checked then geburt := geburt + [0];					

Das muss jetzt ausgeführt werden, nachdem Form2 geschlossen wurde (also hinter das Form2.ShowModal; diese Methode "wartet" quasi darauf, dass das Formular wieder geschlossen wird :idea:).

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 31.03.15 21:36 
jaa, da funktioniert das programm wieder komplett :)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 31.03.15 22:39 
Moin!

Fein, dann zeig doch mal die komplette btnRegelnClick-Methode. :les: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mi 01.04.15 17:37 
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:
procedure TForm1.btnRegelnClick(Sender: TObject);
begin
  form2.ShowModal;
  geburt := [];
  ueberleben := [];  
  if Form2.ckgeburt0.Checked then geburt := geburt + [0];
  if Form2.ckgeburt1.Checked then geburt := geburt + [1];
  if Form2.ckgeburt2.Checked then geburt := geburt + [2];
  if Form2.ckgeburt3.Checked then geburt := geburt + [3];
  if Form2.ckgeburt4.Checked then geburt := geburt + [4];
  if Form2.ckgeburt5.Checked then geburt := geburt + [5];
  if Form2.ckgeburt6.Checked then geburt := geburt + [6];
  if Form2.ckgeburt7.Checked then geburt := geburt + [7];
  if Form2.ckgeburt8.Checked then geburt := geburt + [8];

  if Form2.ckueberleben0.checked then ueberleben := ueberleben + [0];
  if Form2.ckueberleben1.checked then ueberleben := ueberleben + [1];
  if Form2.ckueberleben2.checked then ueberleben := ueberleben + [2];
  if Form2.ckueberleben3.checked then ueberleben := ueberleben + [3];
  if Form2.ckueberleben4.checked then ueberleben := ueberleben + [4];
  if Form2.ckueberleben5.checked then ueberleben := ueberleben + [5];
  if Form2.ckueberleben6.checked then ueberleben := ueberleben + [6];
  if Form2.ckueberleben7.checked then ueberleben := ueberleben + [7];
  if Form2.ckueberleben8.checked then ueberleben := ueberleben + [8];
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 01.04.15 18:47 
Moin!

OK. ;) Allerdings :? ziemlich viel gleiche Sachen, oder? :lupe: Ideen, wie man das "einfacher" machen kann? :zwinker: :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mi 01.04.15 20:03 
das geht bestimmt so ähnlich wie bei den shapes
vielleicht so ungefähr? :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
           for i:= 0 to 8 do begin
            ckgeburt:= Tcheckbox(FindComponent('ckgeburt' +IntToStr(i)));
            if form2.ckgeburt.checked then  geburt := geburt + [i];
           end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 01.04.15 21:45 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
das geht bestimmt so ähnlich wie bei den shapes
8)
user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
vielleicht so ungefähr? :
:zustimm:

Allerdings: die Checkboxen sind ja auf Form2, also musst du das FindComponent von Form2 aufrufen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i := 0 to 8 do begin
  ckgeburt := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
  if ckgeburt.checked then
    geburt := geburt + [i];
end;

Da kannst du sogar noch gleich die andere Spalte Checkboxen mit rein nehmen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mi 01.04.15 22:02 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.btnRegelnClick(Sender: TObject);
var ckgeburt, ckueberleben : TCheckBox;
     i : integer;
begin
  form2.ShowModal;
  geburt := [];
  ueberleben := [];

  for i := 0 to 8 do begin
    ckgeburt := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
    if ckgeburt.checked then
      geburt := geburt + [i];
  end;

  for i := 0 to 8 do begin
    ckueberleben := TCheckBox(Form2.FindComponent('ckueberleben' +IntToStr(i)));
    if ckueberleben.checked then
      ueberleben := ueberleben + [i];
  end
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 01.04.15 22:19 
Moin!

:les: :idea: :nixweiss:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.btnRegelnClick(Sender: TObject);
  var
    ckgeburt, ckueberleben: TCheckBox;
    i: Integer;
begin
  Form2.ShowModal;
  geburt := [];
  ueberleben := [];
  for i := 0 to 8 do begin
    ckgeburt := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
    if ckgeburt.checked then
      geburt := geburt + [i];
    ckueberleben := TCheckBox(Form2.FindComponent('ckueberleben' +IntToStr(i)));
    if ckueberleben.checked then
      ueberleben := ueberleben + [i];
  end;
end;


Ich möchte dir aber noch einen anderen Ansatz zeigen, wie man das Problem auch lösen könnte: mit einer lokalen Funktion: :think:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.btnRegelnClick(Sender: TObject);

  function GetRuleSet(const AName: String): TRegeln;
    var
      CheckBox: TCheckBox;
      i: Integer;
  begin
    Result := [];
    ... // hier musst du jetzt ran ;)
  end;

begin
  Form2.ShowModal;
  ueberleben := GetRuleSet('ckueberleben');
  geburt := GetRuleSet('ckgeburt');
end;

Probier mal. :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mo 13.04.15 16:01 
so jetzt sind die ferien wieder vorbei und internet wieder da :P ich hab auch die letzten zwei wochen drüber nachgedacht wie das gehen könnte, aber ehrlich gesagt finde ich die funktionen noch etwas unverständlich :(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 13.04.15 16:38 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
so jetzt sind die ferien wieder vorbei und internet wieder da :P
Ah, du bist ja doch noch dabei! :D Ich hatte schon befürchtet, die "Hausaufgabe" ist erledigt, die Note gerettet, und auf wiedersehen Programmiererei... :P Schön, dass du (immer) noch Interesse hast. :zustimm:

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
ich hab auch die letzten zwei wochen drüber nachgedacht wie das gehen könnte, aber ehrlich gesagt finde ich die funktionen noch etwas unverständlich :(
OK, dann nehmen wir doch einfach mal das entsprechende (Teil-)Stück Code von oben (deine Version):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  geburt := [];
  for i := 0 to 8 do begin
    ckgeburt := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
    if ckgeburt.checked then
      geburt := geburt + [i];
  end;

Im Prinzip muss díeser Teil jetzt - etwas allgemeiner formuliert, die Ansätze siehst du ja schon in meinem Code - da irgendwie "rein". Probier einfach mal, ist nicht schlimm, wenn´s nicht sofort passt. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mo 13.04.15 17:30 
ist das dann vielleicht in etwa so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.btnRegelnClick(Sender: TObject);

  function GetRuleSet(const AName: String): TRegeln;
    var
      CheckBox: TCheckBox;
      i: Integer;
  begin
    Result := [];
    for i := 0 to 8 do begin
    checkbox := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
    if checkbox.checked then
      result := result + [i];
      end;...
  end;

begin
  Form2.ShowModal;
  ueberleben := GetRuleSet('ckueberleben');
  geburt := GetRuleSet('ckgeburt');
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 13.04.15 20:57 
Moin!

Ja, das ist schon ganz gut. Allerdings beachtest du noch nicht den übergebenen Namen in der Funktion. :idea: Und dann noch die 3 Punkte entfernen, und schon sollte sich das kompilieren lassen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mo 13.04.15 21:11 
ich habe keine ahnung was ich ändern muss :(
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 13.04.15 22:05 
Moin!

user profile iconNini hat folgendes geschrieben Zum zitierten Posting springen:
ich habe keine ahnung was ich ändern muss :(
OK, dann gaaanz langsam. ;)

Das ist der Aufruf der Funktion:
ausblenden Delphi-Quelltext
1:
ueberleben := GetRuleSet('ckueberleben');					

In der Funktion ist dann die Textkonstante als Parameter vorhanden:
ausblenden Delphi-Quelltext
1:
function GetRuleSet(const ANameString): TRegeln;					

Mach mal folgenden Test:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.btnRegelnClick(Sender: TObject);

  function GetRuleSet(const AName: String): TRegeln;
  begin
    ShowMessage(AName); // Test-Ausgabe, was passiert?
  end;

begin
  Form2.ShowModal;
  ueberleben := GetRuleSet('ckueberleben');
  geburt := GetRuleSet('ckgeburt');
end;

Probier das mal aus. :lupe: :think:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Di 14.04.15 19:47 
so also wenn ich btnRegeln öffne und dann schließe kriege ich ein Nachrichtenfeld in dem ckGeburt steht und wenn ich das geschlossen habe darunter ein Feld auf dem ckueberleben steht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 14.04.15 23:16 
Moin!

OK, dann ändere das mal so ab:
ausblenden Delphi-Quelltext
1:
2:
ueberleben := GetRuleSet('hallo');
geburt := GetRuleSet('holla');

Und, was passiert? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nini Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 170
Erhaltene Danke: 12



BeitragVerfasst: Mi 15.04.15 17:58 
da kommt dann als text holla bzw. hallo
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 15.04.15 22:40 
Moin!

Und, kapiert was da mit dem Parameter AName passiert? :zwinker:

Dann jetzt nochmal der Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.btnRegelnClick(Sender: TObject);

  function GetRuleSet(const AName: String): TRegeln;
    var
      CheckBox: TCheckBox;
      i: Integer;
  begin
    Result := [];
    for i := 0 to 8 do begin
      checkbox := TCheckBox(Form2.FindComponent('ckgeburt' +IntToStr(i)));
      if checkbox.checked then
        result := result + [i];
    end;
  end;

begin
  Form2.ShowModal;
  ueberleben := GetRuleSet('ckueberleben');
  geburt := GetRuleSet('ckgeburt');
end;

Was passt hier also noch nicht?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.