Autor Beitrag
kežman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

WIN XP HE
D6 Prof
BeitragVerfasst: Do 10.02.05 16:28 
Hey Leute!
Habe eine mir als Neuling unverständliche Fehlermeldung beim Compilen bekommen.
Der Wert der Variable i soll angeblich niemals benutzt werden.
Nur verstehe ich nicht was hier falsch sein soll?
Werkle wiedermal seit einigen Stunden an so einem Kleinkram rum - das hindert ungemein :(

Ich hoffe jemand erfahrenes kann mir helfen!

Danke!

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:
39:
40:
41:
42:
43:
procedure TForm1.btOeffnenClick(Sender: TObject);
var
 i : integer;
 j : integer;
begin
 i := 0;
 hDaten := tDaten.create;
 hDaten.create;
 with self do
  begin
   MaxVereine;
   MaxSpieler;
  end;

 if ( VeMax > 0 ) then
{Grundknotenerstellung}
  begin
   if(  Frame21.TreeView1.Selected = nil  ) then
    begin
     with Frame21.TreeView1.Items.AddFirst(  nil,  'Datensatz' ) do
      begin
       Selected := true;
      end;
    end;
  end;
{Vereinsknotenerstellung}
 while(i <= VeMax) do
  self.GetVerein(i, hVerein);
  with Frame21.TreeView1.Items.AddChildFirst( Frame21.TreeView1.Selected, hVerein.Name ) do
   begin
    MakeVisible;
    Selected := true;
   end;
  i:=hVerein.ID;
  inc(i);
  j:=0;
    while (j <= SpMax) do
     begin
      self.getSpieler(j, hSpieler);
      Frame21.TreeView1.Items.AddChild(Frame21.TreeView1.Selected, hSpieler.Nachname + ', ' + hSpieler.Nachname);
      inc(j);
     end;
  end;


Zuletzt bearbeitet von kežman am Do 10.02.05 19:46, insgesamt 1-mal bearbeitet
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 16:34 
Zitat:
Der Wert der Variable i soll angeblich niemals benutzt werden.

das ist aber nur ein hinweis des kompilers und keine fehlermeldung. dein programm sollte trotzdem laufen. die fehlersuche kannst du dir also sparen.
kežman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

WIN XP HE
D6 Prof
BeitragVerfasst: Do 10.02.05 16:38 
retnyg hat folgendes geschrieben:
Zitat:
Der Wert der Variable i soll angeblich niemals benutzt werden.

das ist aber nur ein hinweis des kompilers und keine fehlermeldung. dein programm sollte trotzdem laufen. die fehlersuche kannst du dir also sparen.


Ja, schon ... nur entsteht dadurch wohl die Endlosschleife, die mein Programm abstürzen lässt :/
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 10.02.05 16:40 
retnyg hat folgendes geschrieben:
die fehlersuche kannst du dir also sparen.

Da fehlt doch bestimmt ein begin nach while(i <= VeMax) do.

_________________
Ciao, Sprint.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 16:42 
Kanns sein dass du die Variable i doppelt benutzt. oder was tut denn das hier:

ausblenden Delphi-Quelltext
1:
2:
3:
 i:=hVerein.ID;
  inc(i);   
  j:=0;


Kann mir nicht vorstellen, dass das so richtig ist :gruebel:
kežman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

WIN XP HE
D6 Prof
BeitragVerfasst: Do 10.02.05 16:53 
Karlson hat folgendes geschrieben:
Kanns sein dass du die Variable i doppelt benutzt. oder was tut denn das hier:

ausblenden Delphi-Quelltext
1:
2:
3:
 i:=hVerein.ID;
  inc(i);   
  j:=0;


Kann mir nicht vorstellen, dass das so richtig ist :gruebel:


Das war nur ein Test. Vergaß es rauszunehmen.
Trotzdem funktioniert das nicht.

Der gepostete Code ist der gesamte Bereich in dem i vorkommt.
Alle whiles haben u.A. auch ein das folgende do
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 16:55 
tip: setze breakpoints. der debugger bleibt dann in deiner endlosschleife hängen und dann kannst du mit einzelschritt schauen warum das so ist.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 17:13 
Sprint hat die Lösung allerdings bereits gepostet... es fehlt ein Begin

Zitat:
orginal geschrieben von Sprint
Da fehlt doch bestimmt ein begin nach while(i <= VeMax) do.


nur so nebenbei stimmt die Compilerwarnung. I dient nur als Zählvariable, der Wert wird zwar verglichen und auch hochgezählt, aber niemals benutzt :)

Diese Compilerwarnung gehört allerdings wohl eher in die Kategorie "Danke für den Tipp, aber passt schon ;)"


Zuletzt bearbeitet von Karlson am Do 10.02.05 17:14, insgesamt 1-mal bearbeitet
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 10.02.05 17:14 
Sonst würde Inc(I) irgendwie keinen Sinn machen...

_________________
Ciao, Sprint.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 17:20 
schon die while schleife würde keinen sinn machen, da VeMax ja nirgends verändert wird. VeMax ist wohl die anzahl der Vereine, und wenn diese 0 ist, kann die nächste Zeile schwer ausgeführt werden, es sei denn VeMax wird innerhalb der whileschleife neu abgefragt. Oder ist VeMax ein definierter Bezeichner oder eine Variable?
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 10.02.05 17:23 
Karlson hat folgendes geschrieben:
Diese Compilerwarnung gehört allerdings wohl eher in die Kategorie "Danke für den Tipp, aber passt schon ;)"

Passt eher zu "Der Compiler war mal wieder schlauer als ich" Kategorie.

_________________
Ciao, Sprint.
kežman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

WIN XP HE
D6 Prof
BeitragVerfasst: Do 10.02.05 17:27 
Hehe alles klar ...
Lag an dem Begin ... hab es nur flüchtig lesen können, da ich gerade kurz jemanden abholen musste.

Danke sehr - ziemlich blöd gelaufen :oops: :oops: :oops:


Zuletzt bearbeitet von kežman am Do 10.02.05 17:54, insgesamt 1-mal bearbeitet
kežman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

WIN XP HE
D6 Prof
BeitragVerfasst: Do 10.02.05 17:53 
wech