Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.373 Beiträge
 
Delphi 12 Athens
 
#11

Re: Calculate Min Max of integer

  Alt 3. Dez 2009, 10:32
Delphi-Quellcode:
procedure TMyInt.SetValue(IntValue: Integer);
begin
  if not FInit then
  begin
    FValue := IntValue;
    FMax := FValue;
    FMin := FValue;
    FInit := True;
  end
  else
    if FValue <> IntValue then
    begin
      FValue := IntValue;
      if FValue > FMax then
        FMax := FValue;
      if FValue < FMin then
        FMin := FValue;
    end;
end;
Delphi-Quellcode:
procedure TMyInt.SetValue(IntValue: Integer);
begin
  FValue := IntValue;
  if not FInit then begin
    FMax := FValue;
    FMin := FValue;
    FInit := True;
  end
  else if FValue > FMax then FMax := FValue
  else if FValue < FMin then FMin := FValue;
end;
I do not understand what he wants her more.
- the codes for TMyInt all work
- only the position of the variable, and that everything is constantly new initializes what the problem

Delphi-Quellcode:
procedure TForm3.Timer1Timer(Sender: TObject);
var
  temp: TMyInt; << this is not local, but must be
                    declared globally in the form
begin
  temp.Init; << and it should not be constantly re-initialized
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat