Le 04/04/2021 à 02:41, James Richters a écrit :
That looks almost perfect.. can I suppress the trailing zeros with the format command without losing the alignment?

As far as I know, no ...

Not  with just the RTL.
Anyway I have personal code for this, you can extract and customize it to yours needs, it's released under LGPL :

program Format_Example;
uses
    sysutils,uReal_Formatter,uuStrings;
procedure FF( _d: double);
var
   S: String;
begin
     S:= Fixe_MinE( Format_Float(_d, True, 3), 7);
     WriteLn( S);
end;

begin
     FF(0.5);
     FF(2.53);
     FF(12.5);
end.

------- Output -----

  0.5
  2.53
 12.5

You can find  the used units there:

https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uReal_Formatter.pas

https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/uuStrings.pas (just extract functions  Fixe_MinE / Fixe_Min0 or you will have to use a bunch of other units from the same directory https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/)

https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/02_Units/u_sys_.pas

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to