Autor Beitrag
F4n4T!C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Mo 26.11.07 10:50 
hi leute...ich habe ein klitzekleines, aber erhebliches Problem...ich poste mal schnell den quelltext

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure vergleich1(n:integer);
begin
     if ((z<(j)) and ((feld1[n])=(feld2[(z)]))) then
       begin
         gleich:=true;
       end
     else
       begin
         if z=j then
           begin
             vergleich2(n);<- Fehler "undefinierter Bezeichner versuch2"
           end;
         gleich:=false;
         z:=z+1;
         vergleich1(n);
       end;
end;
procedure vergleich2(n:integer);
begin
  showmessage('geht');
end;


mein info lehrer sagte mir, dass der compiler ganz einfach den "versuch 2" nicht kompiliert hat, er sagte mir etwas von einer "forward deklaration" jedoch wusste er im moment nicht wie das geht, deshalb wollte ich mich mal ganz schnell hierher wenden, und fragen ob ihr wisst, wie ich das lösen kann, dass der auch den "vergleich2" beim programm aufruf so deklariert, dass ich in vergleich1 vergleich2 aufrufen kann...dankje für ewure hilfe

mfg F4n4T!C

Moderiert von user profile iconjasocul: Delphi-Tags hinzugefügt
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 26.11.07 10:57 
Tausche einfach mal die Reihenfolge der Prozeduren.
Eine Forward-Deklaration würde auch funktionieren, fände ich aber übertrieben.
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Mo 26.11.07 12:00 
Der Vollständigkeit halber: Deine Prozedur Vergleich2 ist dem Compiler in der Prozedur 1 noch nicht bekannt er ist ja noch da oben und kennt sie noch nicht. Eine Forward-Deklaration macht nun nichts weiter als die Prozudur sozusagen schon vorher mal anzumelden. Dazu musst du nur! die Prozedurdeklaration in den interface-Teil setzen. Dann kennt er/der Compiler nämlich die und weiß wie er die aufrufen muss.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 26.11.07 13:03 
@Allesquarks: Bitte Forward-Deklaration nichtmit regulärer Interface-Deklaration verwechseln.

Eine Forward-Deklaration muss nämlich gekennzeichnet werden, eine Interface-Deklaration steht einfach nur im Interface und wird dann implementiert.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
F4n4T!C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Mo 26.11.07 13:27 
ja die beiden prozeduren vertauschen hat mir mein lehrer auch gesagt, aber ich muss in der prozedur "versuch2" bei fortgeschrittenem stadium des programmes wieder auf versuch 1 zugreifen, damit hätten wir wieder das gleiche problem...

kann mir jemand ein stück quellcode schreiben, oda nen link geben, wie ich eine Forward-Deklaration schreibe?

danke schonmal für eure antworten,
mfg F4n4T!C
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 26.11.07 13:39 
Schreib in deinen Editor einfach an eine Freie Stelle forward und drücke F1. HTH

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
F4n4T!C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Mo 26.11.07 13:51 
also um das ganze mal zusammenzufassen, ich schreibe vor meine ganzen prozeduren ganz einfach die prozeduren köpfe, und schreibe dahinter "forward"

also in meinem beispiel

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:
 procedure vergleich1(n:integer); forward;
 procedure vergleich2(n:integer); forward;

 procedure vergleich1(n:integer);  
begin  
     if ((z<(j)) and ((feld1[n])=(feld2[(z)]))) then  
       begin  
         gleich:=true;  
       end  
     else  
       begin  
         if z=j then  
           begin  
             vergleich2(n);<- Fehler "undefinierter Bezeichner versuch2"  
           end;  
         gleich:=false;  
         z:=z+1;  
         vergleich1(n);  
       end;  
end;  
procedure vergleich2(n:integer);  
begin  
  showmessage('geht');  
end;


danke sehr^^ habt mir sehr geholfen (=

Moderiert von user profile iconjasocul: Delphi-Tags hinzugefügt
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 26.11.07 14:04 
Bitte fasse deinen Code mal noch in Delphi-Tags ein. TIA.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
F4n4T!C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Mi 28.11.07 06:50 
wie fasst man seinen code in delphi tags?^^
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mi 28.11.07 07:54 
Nur mal so am Rande:
Deine Prozedur heißt procedure vergleich2(n:integer);
Bei der Fehlermeldung schreibst du
user profile iconF4n4T!C hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
vergleich2(n);<- Fehler "undefinierter Bezeichner versuch2"					


Welches davon war jetzt ein Tippfehler?! ;-)

_________________
Anonymes Eckenkind
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 28.11.07 08:14 
user profile iconMiri hat folgendes geschrieben:
Welches davon war jetzt ein Tippfehler?! ;-)

Rate mal.

_________________
Na denn, dann. Bis dann, denn.


Zuletzt bearbeitet von alzaimar am Mi 28.11.07 09:18, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 28.11.07 09:04 
user profile iconF4n4T!C hat folgendes geschrieben:
wie fasst man seinen code in delphi tags?^^
Entweder vor und nach dem Quelltext oben über dem Eingabebereich unter Bereiche das + neben Delphi klicken oder selbst <span class="inlineSyntax"><span class="codecomment">{PROTECTTAGe31a6279eb07b72ed8d59b3f9c8ec39d}</span></span> schreiben ;-):
www.delphi-forum.de/...19,27,32&popup=1
F4n4T!C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: So 02.12.07 10:47 
ja also das mit dem versuch und vergleich....da hab ich etwas überarbeitet, aber vergessen versuch in vergleich umzunennen^^ sry

das prob hat sich ja jetzt bestritten..bin schu beim 2. prob :D