procedure Str(X [: Width [: Decimals ]]; var S:string);
Code: Select all
Flt : Real;
I : Integer;
St1,St2 : String;
Begin
Flt:=4.2345;
I:= 6;
Str(Flt:5:2,St1); {will output ‘ 4.23’}
Str(I:4,St2); {will output ‘ 6’}
Str(Flt:1:2,St1); {will output ‘4.23’}
End;
Of course there are similar expressions with the Write and Writeln procedures, however with the large number of different displays this seems difficult to carry out (unless a system for a universal text output is created).
Conversion of floating point to a string would go a long way. There are of course numbers that require exponentials; however this should cover the most important cases. ME has not seemed to be willing to provide string formatting for floating point numbers in the PIC versions yet, however with the increased capacity of dsPIC, should not this be viable?
Wished for the next release (not necessarily in exact same syntax, for instance a function would have been more convenient).