calculator/src/support.pas
2018-11-04 11:59:40 +05:00

32 lines
774 B
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.