[fpc-devel] Default IntToStr operator for '+' symbol.

Skybuck Flying skybuck2000 at hotmail.com
Fri Apr 29 19:50:26 CEST 2011


----- Original Message ----- 
From: "Felipe Monteiro de Carvalho" <felipemonteiro.carvalho at gmail.com>
To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
Sent: Friday, 29 April, 2011 10:23 AM
Subject: Re: [fpc-devel] Default IntToStr operator for '+' symbol.


> The Pascal way to avoid using too much IntToStr is:
>
> begin
>  s := Format('%d %d', [X, Y]);
> end;
>
> Much shorter, no?

Barely, I absolutely hate that function, it's very unnatural and reminds me 
of C.

It's pretty stupid though sometimes it can be handy to layout floats or 
currency or do special things, like add zeros in front.

However I suspect there is a better way to layout these variables.

I just had an idea how to better layout floats and such. The old way of 
laying them out in writeln can be used which I love and is great:

Example:

begin
    s := vSomeFloat:16:16 + ' ' + vSomeFloat:16:16;
end;

Perhaps someone can (later) come up with nice format specifiers.

There is also a huge benefit of this new way above:

The format specifier is immediatly associated with the variables no need to 
count place like in your case.

(For two that is not much of a problem but it gets a bit nasty for 10 and 
beyond)

Bye,
  Skybuck. 




More information about the fpc-devel mailing list