mirror of
https://github.com/nxshock/calculator.git
synced 2025-04-18 07:41:51 +05:00
32 lines
774 B
ObjectPascal
32 lines
774 B
ObjectPascal
unit Support;
|
||
|
||
{$mode objfpc}{$H+}
|
||
|
||
interface
|
||
|
||
uses
|
||
SysUtils;
|
||
|
||
function ClearExpression(input: string): string; // Удаление лишних символов из выражения
|
||
|
||
implementation
|
||
|
||
function ClearExpression(input: string): string;
|
||
var
|
||
i: integer;
|
||
begin
|
||
// Замена десятичного разделителя с точки на запятую
|
||
Result := stringreplace(input, '.', ',', [rfReplaceAll, rfIgnoreCase]);
|
||
|
||
// Удаление всех лишних символов
|
||
i := 1;
|
||
while i <= length(Result) do
|
||
if not ((Result[i]) in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ',', '+', '-', '*', '/', '(', ')']) then
|
||
Delete(Result, i, 1)
|
||
else
|
||
i := i + 1;
|
||
end;
|
||
|
||
end.
|
||
|