📄 calcunit.pas
字号:
theList.Add(str);
theList.Add(strTemp[i]);
j:=i+1;
end;
end;
str:=Copy(strTemp,j,i-j);
theList.Add(Trim(str));
theList.Add(Trim(strTemp[i]));
If bCalcOrCommond then
begin
i:=0;
while i <= theList.Count-1 do
begin
If Trim(theList.Strings[i])='' then
theList.Delete(i)
else
i:=i+1;
end;
end;
i:=0;
while i<=(theList.Count-1) do
begin
theList.Strings[i]:=Trim(theList.Strings[i]);
If bCalcOrCommond then
begin
If theList.Count>1 then
theList.Delete(i)
else
i:=i+1;
end else
begin
If IsInOperatorsArray(Uppercase(Trim(theList.Strings[i]))) then
begin
If (Uppercase(Trim(theList.Strings[i]))='SETFONT')or
(Uppercase(Trim(theList.Strings[i]))='BKCOLOR')or
(Uppercase(Trim(theList.Strings[i]))='BACKCOLOR')or
(Uppercase(Trim(theList.Strings[i]))='FULLSCREEN')OR
(Uppercase(Trim(theList.Strings[i]))='FULLSCR')OR
(Uppercase(Trim(theList.Strings[i]))='REV')OR
(Uppercase(Trim(theList.Strings[i]))='REVERT') then
theList.Delete(i)
else
i:=i+1;
end else
begin
If (not IsFloat(Trim(theList.Strings[i]))) then
begin
Result:=Result+theList.Strings[i];
theList.Delete(i);
end
else i:=i+1;
end;
end;
end;
end;
function TCalcForm.CalcNonoKh(theList: TStringList): Extended;
var i,j: Integer;
dTemp: Extended;
begin
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'PI') then
begin
dTemp:=3.1415926535897932384626433832795;
theList.Strings[i]:=FloatToStr(dTemp);
end;
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (theList.Strings[i] = '!') then
begin
dTemp:=1;
For j:=1 to Trunc(StrToFloat(theList.Strings[i-1])) do
begin
dTemp:=dTemp*j;
end;
theList.Delete(i-1);
theList.Strings[i-1]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (theList.Strings[i] = '^') then
begin
dTemp:=Power(StrToFloat(theList.Strings[i-1]),StrToFloat(theList.Strings[i+1]));
theList.Delete(i-1);
theList.Delete(i);
theList.Strings[i-1]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'SQR') then
begin
dTemp:=Sqr(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'SQRT') then
begin
dTemp:=Sqrt(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (theList.Strings[i] = '%') then
begin
dTemp:=(Trunc(StrToFloat(theList.Strings[i-1])) mod Trunc(StrToFloat(theList.Strings[i+1])));
theList.Delete(i-1);
theList.Delete(i);
theList.Strings[i-1]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'INT')OR(UpperCase(theList.Strings[i]) = 'TRUNC') then
begin
dTemp:=Trunc(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'ROUND') then
begin
dTemp:=Round(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'ABS') then
begin
dTemp:=Abs(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'FRAC') then
begin
dTemp:=Frac(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'ARCTAN') then
begin
dTemp:=Arctan(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'SIN') then
begin
dTemp:=Sin(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'COS') then
begin
dTemp:=Cos(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'TAN') then
begin
dTemp:=Tan(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'ARCSIN') then
begin
dTemp:=ArcSin(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'ARCCOS') then
begin
dTemp:=ArcCos(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'LN') then
begin
dTemp:=Ln(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'LOG2') then
begin
dTemp:=Log2(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
i:=0;
while i<=(theList.Count-1) do
begin
If (UpperCase(theList.Strings[i]) = 'LOG10') then
begin
dTemp:=Log10(StrToFloat(theList.Strings[i+1]));
theList.Delete(i);
theList.Strings[i]:=FloatToStr(dTemp);
end else
i:=i+1;
end;
//******************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -