Autor Beitrag
Sanne
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Di 17.12.02 19:55 
also ich steh vor folgendem problem:
ausblenden volle Höhe 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:
var
i: integer;
aktgroesse:         integer;
groesse:            integer;

begin
groesse:=strtoin(label9.caption);
aktgroesse:=0;
i:=7;
scheibe[i]:=power(2,i);
repeat
aktgroesse:=aktgroesse+scheibe[i];
if groesse<aktgroesse
then aktgroesse:=aktgroesse-scheibe[i];
dec[i];
until
i<0;
ok:=groesse>aktgroesse
if ok then
case i of
7:DBcheckbox1.checked:=true;
      6:DBcheckbox2.checked:=true;
      5:DBcheckbox3.checked:=true;
      4:DBcheckbox4.checked:=true;
      3:DBcheckbox5.checked:=true;
      2:DBcheckbox6.checked:=true;
      1:DBcheckbox7.checked:=true;
      0:DBcheckbox8.checked:=true;
.
..

......
end;

jetzt hab ich das problem- daß der die eckige klammer von scheibe[i] als variable net will- aber ich muß das doch irgendwie definieren oder? wie soll ich das denn dann machen???
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Di 17.12.02 20:06 
Wenn ich mich nict täusche muss es

ausblenden Quelltext
1:
dec(i);					


heißen.

Und was ist scheibe für eine Variable?
Sanne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Di 17.12.02 20:10 
scheibe ist n shape- was für ne variable weiß ich nicht- weiß ja auch nicht wie ich die definieren soll- i ist ja veränderlich und das soll dann für alle scheiben gelten...
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Di 17.12.02 20:13 
Shape ist ja auch ein Object und kein Integer wie i.
Sehe ich das richtig, dass du auf die Größe aller Shapes zugreifen möchtest?
Sanne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Di 17.12.02 20:32 
ja ich will auf die größe der shapes zurückgreifen- die sind ja definiert mit 2^i- i wird ja von 7 bis 0 verkleinert- somit verändert sich ja auch die größe der shapes- zumindest sollte es das tun... weiß nur nicht iwe!!!! :(
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Di 17.12.02 22:40 
Um auf die Shapegröße zuzugreifen musst du auch die Eigenschaft Größe auslesen. Das geht so:

ausblenden Quelltext
1:
scheibe.Height					


Nehmen wir mal an du hast 10 Shapes aud deinem Formular. Benenne Sie einfach Scheibe1, Scheibe2, Scheibe3 ... Scheibe10.

Nun kannst du mit dem Befehl FindComponent mit Verbindung der Laufvariable i die Größe der Shapes in einer for-Schleife auswerten.

ausblenden Quelltext
1:
2:
3:
4:
groesse:=0;
for i:=1 to 10 do begin
  groesse:=groesse+(FindComponent('Scheibe'+IntToStr(i)) as TShape).Height;
end;
Sanne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 18.12.02 00:00 
klingt logisch- dann werd ich das mal so probieren- kann ich dann das dec komplett vergessen oder?
hitstec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 295



BeitragVerfasst: Mi 18.12.02 09:08 
Ähmm, ja.
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Mi 18.12.02 13:07 
So wie ich das sehe, musst du deine Scheibe so deklarieren: Var Scheibe: Array of TShape

_________________
If accidentally read, induce vomitting.