i found two methods,
you can use function strip to strip off the last
characters, or function real_to_string which does the
rounding off, these i found on the net sometime back
and i have modified them for my own use, if they are
useful do the same. anybody with a different idea?
{*********************************************************************}
{ Strip('L',' ',' bob') returns 'bob' }
{ Strip('R','5','56345') returns '5634' }
{ Strip('B','H','HASH') returns 'as' }
{ strip('A','E','fleetless') returns fltlss }
{*********************************************************************}
Function Strip(L,C:char;Str:string):string;
{L is left,center,right,all,ends}
var
I : byte;
begin
Case Upcase(L) of
'L' : begin {Left}
While (Str[1] = C) and (length(Str) > 0) do
Delete(Str,1,1);
end;
'R' : begin {Right}
While (Str[length(Str)] = C) and (length(Str) > 0)
do
Delete(Str,length(Str),1);
end;
'B' : begin {Both left and right}
While (Str[1] = C) and (length(Str) > 0) do
Delete(Str,1,1);
While (Str[length(Str)] = C) and (length(Str) > 0)
do
Delete(Str,length(Str),1);
end;
'A' : begin {All}
I := 1;
Repeat
If (Str[I] = C) and (length(Str) > 0) then
Delete(Str,I,1)
else
I := succ(I);
Until (I > length(Str)) or (Str = '');
end;
end;//case
//Strip := Str;
Result:=Str;
end; {Func Strip}
{***************************************************************************}
{ Real_to_string(1345.41956,2) returns 1345.42 }
{***************************************************************************}
function
Real_to_string(Number:real;Decimals:byte):string;
const floating = 255;
var
Temp : string;
begin
Str(Number:20:Decimals,Temp);
repeat
If copy(Temp,1,1) = ' ' then delete(Temp,1,1);
until copy(temp,1,1) <> ' ';
If Decimals = Floating then
begin
Temp := Strip('R','0',Temp);
If Temp[Length(temp)] = '.' then
Delete(temp,Length(temp),1);
end;
Result:=Temp;
end;
//joseph fuchaka
//[EMAIL PROTECTED]
//have a nice day.
____________________________________________________________________________________
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/