Autor Beitrag
muetzenjoe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 56

Win XP / Win Vista
# Delphi 6 Enterprise; # HTML Editor Phase 5; # Ulead Gif Animator 5;
BeitragVerfasst: Di 01.05.07 22:40 
hallo erstmal!

ich bastel gerade wieder ein wenig und stecke wieder mal fest.

ich wollte mir eine funktion oder procedure erstellen um mir etwas code zu sparen. ich müsste sonst sehr oft folgendes tippen:
ausblenden Delphi-Quelltext
1:
if(panel3.caption='X')and(panel4.caption='X')and(panel5.caption='X') then result:='1';					


nun dachte ich, ich mache es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function check_win():string;
begin
if (panel3.caption='X')and(panel4.caption='X')and(panel5.caption='X') then result:='1';
end;

ging nicht also dachte ich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure check_win();
begin
if (panel3.caption='X')and(panel4.caption='X')and(panel5.caption='X') then result:='1';
end;


aber auch das geht nicht, weil dann immer panel3 nicht anerkannt wird. wieso? wie mache ich es sonst?

später aufrufen wollte ich es dann einfach nur mit:
ausblenden Delphi-Quelltext
1:
if check_win='1' then...					


sicherlich falsch aber wie sonst?

vielen dank im vorraus!

_________________
Sind wir nicht alle ein wenig Newbee???
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Di 01.05.07 22:46 
Probiers mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function check_win:string;
begin
  if (panel3.caption='X')and(panel4.caption='X')and(panel5.caption='X') 
    then result:='1'
    else result:='0';
end;

Der Aufruf ist ok.

Bye!
ub60
muetzenjoe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 56

Win XP / Win Vista
# Delphi 6 Enterprise; # HTML Editor Phase 5; # Ulead Gif Animator 5;
BeitragVerfasst: Di 01.05.07 22:50 
bekomme wieder die meldung:
[Error] Unit1.pas(87): Undeclared identifier: 'panel3'

_________________
Sind wir nicht alle ein wenig Newbee???
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 01.05.07 22:59 
Moin!

Zunächstmal: wenn du Wahrheitswerte ermitteln willst, warum verwendest du dann nicht als Ergebnistyp Boolean, statt String? :gruebel:

Dann: wenn deine Funktion nicht Mitglied der Formularklasse ist, dann kannst du keine Komponenten des Formulars adressieren. Lösung: Die Funktion in die Formularklasse aufnehmen oder Form1.Panel3... schreiben. :idea:

Und zum Schluss: das sieht verdächt nach TicTacToe aus. :P Schau mal hier, vielleicht kommst du damit weiter. :D

cu
Narses

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

Win XP / Win Vista
# Delphi 6 Enterprise; # HTML Editor Phase 5; # Ulead Gif Animator 5;
BeitragVerfasst: Di 01.05.07 23:03 
naja es ist eine "art" tictactoe und ich brauche string (naja oder integer) weil das ja nur eine zeile der funtkion ist die dann halt "1" ausgeben soll. im enteffekt kommen aber noch einige zeilen dazu sodass die antwort auch variiert.

aber ich versuchs mal weiter und melde mich wieder. thx!

edit:

jo... das wars! einfach ein form1. davor und alles wird gut!

naja sagte ich ja... denkfehler!

_________________
Sind wir nicht alle ein wenig Newbee???
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 01.05.07 23:07 
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.