summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw11309.pp
blob: 104f19a70a4e1a178211dde96ffc5fdb6167997f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{$ifdef fpc}
{$mode delphi}
{$endif}

uses
  SysUtils;

var
  csMoney : string;

Function Format_Currency_String1(sMoney : string) : string;
var
aCurrency : Currency;
begin
  TRY
aCurrency := strtoCurr(sMoney);
  EXCEPT
   on E: EConvertError do aCurrency := 0;
  END;
//result := CurrToStrF(currBetrag,ffFixed,2);
result := FloatToStrF(aCurrency,ffFixed,19,2);
end;

Function Format_Currency_String2(sMoney : string) : string;
var
aCurrency : real;
begin
  TRY
aCurrency := strtofloat(sMoney);
  EXCEPT
   on E: EConvertError do aCurrency := 0;
  END;
result := FloatToStrF(aCurrency,ffFixed,19,2);
end;

begin
  csMoney:='58'+DecimalSeparator+'195';
  writeln(Format_Currency_String1(csMoney));
  writeln(Format_Currency_String2(csMoney));
  if Format_Currency_String1(csMoney)<>'58'+DecimalSeparator+'20' then
    halt(1);
  if Format_Currency_String2(csMoney)<>'58'+DecimalSeparator+'20' then
    halt(2);
  writeln('ok');
end.