Autor Beitrag
christian87
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mo 26.02.07 18:34 
Hi,

Ich habe Probleme mit eine rAugelagerten Prozedur. Habe folgende Prozedur in eine andere Unit ausgelagert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure wand_abfragen(bx,by,x0,y0,x1,y1:integer; ank,gegenk:real);
begin
If ((bx) <= x0) or (bx >= x1 ) then
ank:=-ank;

If ((by)<=y0) or ((by) >=y1) then
gegenk:=-gegenk;
end;


Und so in meiner Hauptunit aufgerufen:

ausblenden Delphi-Quelltext
1:
wand_abfragen(bx,by,x0,y0,x1,y1, ank,gegenk);					


Es werden keine Fehler angezeigt, aber es funktioniert nicht. Wenn ich den Quelltext direkt in die Hauptunit schreibe läufts.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 26.02.07 18:38 
Moin!

Schätze mal, du hast hier was "vergessen": ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure wand_abfragen(bx,by,x0,y0,x1,y1:integer; var ank,gegenk:real);  
begin  
  if (bx <= x0) or (bx >= x1) then  
    ank := -ank;  
  if (by <= y0) or (by >= y1) then  
    gegenk := -gegenk;  
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
christian87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mo 26.02.07 18:45 
Hi,

Ich bin nicht so fit in der Parameterübergabe. Warum muss ich da jetzt var benutzen?
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mo 26.02.07 18:47 
Wenn du einer Prozedur eine Variable übergibst, die in der Prozedur geändert werden soll, musst du diese Variable als var-Parameter übergeben (Da er variabel ist ;) )
In deinem Beispiel sollen die Parameter ank und gegenk einen neuen Wert bekommen, darum musst du sie als Var-Parameter übergeben, darum auch das "var" davor.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 26.02.07 18:47 
Moin!

Die Werte müssen doch wieder aus der Prozedur "raus kommen". ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Bääääär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Mo 26.02.07 18:48 
damit ank und gegenk, wenn sie in der Procedur verändert wurden, auch "außerhalb" der procedure verändert werden (srry, weiß grade nicht, wie ich das erklären soll)

als bsp: inc(var) verändert doch die Variable "var", oder? also sieht die procedure so aus:
ausblenden Delphi-Quelltext
1:
procedure inc(var i:cardinal);					


[edit]
verdammt, 2 waren schneller!
[/edit]


Zuletzt bearbeitet von Bääääär am Mo 26.02.07 18:49, insgesamt 1-mal bearbeitet
christian87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Mo 26.02.07 18:48 
Stimmt klar danke!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 26.02.07 18:53 
Moin!

Markierst du den Thread noch entsprechend, wenn dein Problem gelöst ist? Danke. ;)

cu
Narses

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