酒杯上的碟
esultEdit.Text := FloatToStr(FCurrentValue);
end;
btInverse:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := 1 / FCurrentValue;
end;
btPercent:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := FCurrentValue / 100;
FResultEdit.Text := FloatToStr(FCurrentValue);
end;
btSqrt:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := Sqrt(FCurrentValue);
FResultEdit.Text := FloatToStr(FCurrentValue);
end;
btMemoryStore:
begin
FMemoryValue := StrToFloat(FResultEdit.Text);
FMemoryValue := FMemoryValue * 1;
FCurrentValue := 0;
end;
btMemoryAdd:
begin
TempValue := FMemoryValue;
FMemoryValue := StrToFloat(FResultEdit.Text);
FMemoryValue := (FMemoryValue * 1) + TempValue;
end;
btMemoryRecall:
begin
FResultEdit.Text := FloatToStr(FMemoryValue);
FCurrentValue := 0;
end;
btMemoryClear:
begin
FMemoryValue := 0;
end;
btEquals:
if FState <> csNone then
begin
FBackSpaceValid := False;
FCurrentValue := StrToFloat(FResultEdit.Text);
if FRepeatValue = 0 then
begin
FRepeatValue := FCurrentValue;
FCurrentValue := FLastValue;
end;
FLastValue := FRepeatValue;
case FState of
csAdd:
FCurrentValue := FCurrentValue + FLastValue;
csMultiply:
FCurrentValue := FCurrentValue * FLastValue;
csSubtract:
FCurrentValue := FCurrentValue - FLastValue;
csDivide:
FCurrentValue := FCurrentValue / FLastValue;
end;
FLastValue := FCurrentValue;
FResultEdit.Text := FloatToStr(FCurrentValue);
FCurrentValue := 0;
end;
end; // case ButtonType of...
except
on E: Exception do
begin
FResultEdit.Text := E.Message;
FLastValue := 0;
FCurrentValue := 0;
FRepeatValue := 0;
FState := csNone;
end;
end;
FStatus.Caption := MemoryStoreMap[FMemoryValue = 0];
end;
function TCalculator.GetText: string;
begin
Result := FResultEdit.Text;
end;
procedure TCalculator.SetText(const Value: string);
begin
FResultEdit.Text := Value;
end;
end.
本文链接地址:http://www.oyaya.net/fanwen/view/173009.html
end;
btInverse:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := 1 / FCurrentValue;
FResultEdit.Text := FloatToStr(FCurrentValue);
end;
btPercent:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := FCurrentValue / 100;
FResultEdit.Text := FloatToStr(FCurrentValue);
end;
btSqrt:
begin
FCurrentValue := StrToFloat(FResultEdit.Text);
FCurrentValue := Sqrt(FCurrentValue);
FResultEdit.Text := FloatToStr(FCurrentValue);
end;
btMemoryStore:
begin
FMemoryValue := StrToFloat(FResultEdit.Text);
FMemoryValue := FMemoryValue * 1;
FCurrentValue := 0;
end;
btMemoryAdd:
begin
TempValue := FMemoryValue;
FMemoryValue := StrToFloat(FResultEdit.Text);
FMemoryValue := (FMemoryValue * 1) + TempValue;
end;
btMemoryRecall:
begin
FResultEdit.Text := FloatToStr(FMemoryValue);
FCurrentValue := 0;
end;
btMemoryClear:
begin
FMemoryValue := 0;
end;
btEquals:
if FState <> csNone then
begin
FBackSpaceValid := False;
FCurrentValue := StrToFloat(FResultEdit.Text);
if FRepeatValue = 0 then
begin
FRepeatValue := FCurrentValue;
FCurrentValue := FLastValue;
end;
FLastValue := FRepeatValue;
case FState of
csAdd:
FCurrentValue := FCurrentValue + FLastValue;
csMultiply:
FCurrentValue := FCurrentValue * FLastValue;
csSubtract:
FCurrentValue := FCurrentValue - FLastValue;
csDivide:
FCurrentValue := FCurrentValue / FLastValue;
end;
FLastValue := FCurrentValue;
FResultEdit.Text := FloatToStr(FCurrentValue);
FCurrentValue := 0;
end;
end; // case ButtonType of...
except
on E: Exception do
begin
FResultEdit.Text := E.Message;
FLastValue := 0;
FCurrentValue := 0;
FRepeatValue := 0;
FState := csNone;
end;
end;
FStatus.Caption := MemoryStoreMap[FMemoryValue = 0];
end;
function TCalculator.GetText: string;
begin
Result := FResultEdit.Text;
end;
procedure TCalculator.SetText(const Value: string);
begin
FResultEdit.Text := Value;
end;
end.
《酒杯上的碟(第7页)》