Einzelnen Beitrag anzeigen

FCCrobi2

Registriert seit: 15. Jan 2015
5 Beiträge
 
#6

AW: Variable aus anderer Procedure auslesen

  Alt 15. Jan 2015, 21:09
Zeig doch mal was du hast und wo du das benutzen möchtest, dann kann man auch konkret antworten.
Der ganze Quelltext wäre hier viel zu lang,desswegen ist hier sehr viel rausgekürzt, ich hoffe aber es ist alles wichtige dafür drin.
Die Variablen EA,Quote1 und Quote2 berechne ich in Procedure 1 und benötige sie dort später auch. In der zweiten Procedure brauche ich diese drei allerdings
auch, möchte sie aber nur ungern neu berechnen. Desswegen verzweifle ich die letzten Stunden daran sie in mehreren Procedures nutzen zu können.

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
Elo1,Elo2: integer;
EA,Potenz,Pot,Quote1,Quote2: real;
begin
Elo1:=strtoint(Form1.Edit1.Text);
Elo2:=strtoint(Form1.Edit2.Text);
IF Elo1 > Elo2 then
  begin
  IF Elo1-Elo2>400 then
    begin
    Pot:=1;
    end
  else if Elo1-Elo2<400 then
    begin
    Pot:=(Elo1-Elo2)/400;
    end
  end
else IF Elo1<Elo2 then
  begin
  IF Elo2-Elo1>400 then
    begin
    Pot:=1;
    end
  else IF Elo2-Elo1<400 then
    begin
    Pot:=(Elo2-Elo1)/400;
    end
  else IF Elo1=Elo2 then
    begin
    Pot:=0;
    end
  end;

Potenz := Power(10, Pot);
[B]EA:=1/ (1 + Potenz)[/B];

IF Elo1>Elo2 then
  begin
[B] Quote1:=1/((1-EA)*100)*100;
  Quote2:=1/(EA*100)*100;[/B]
  end
else if Elo1<Elo2 then
  begin
[B] Quote1:=1/(EA*100)*100;
  Quote2:=1/((1-EA)*100)*100;[/B]
  end
else if Elo1=Elo2 then
  begin
[B] Quote1:=2;
  Quote2:=2;[/B]
end;




procedure TForm1.Button5Click(Sender: TObject);
var
z,Einsatz:integer;
begin
z:=0;
z:=Random(100);
Einsatz:=strtoint(Form1.Edit5.Text);
IF Form1.ComboBox3.ItemIndex=0 then begin
    IF [B]z<EA[/B] then
    begin
    Form1.Label23.Caption:=floattostr([B]Quote1*Einsatz[/B])+' Euro gewonnen!';
    end
    else if [B]z>EA[/B] then
    begin
    Form1.Label23.Caption:=floattostr(Einsatz)+' Euro verloren!';
  end
else if Form1.ComboBox3.ItemIndex=1 then begin
    IF [B]z<EA[/B] then
    begin
    Form1.Label23.Caption:=floattostr(Einsatz)+' Euro Verloren';
    end
    else if [B]z>EA[/B] then
    begin
    Form1.Label23.Caption:=floattostr([B]Quote2*Einsatz[/B])+' Euro gewonnen!';
    end;
end;

Geändert von FCCrobi2 (15. Jan 2015 um 21:20 Uhr)
  Mit Zitat antworten Zitat