The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



strff


Unit:SDL_stringl
Class:None
Declaration:function strff (r: extended; FieldWidth, DecP: integer): string;

The Delphi procedure str converts a numeric value to a character string. The use of this procedure is somewhat inconvenient since it involves a separately declared (auxiliary) variable. The function strff provides a remedy to this problem and returns a string of the value r. The field width and the number of decimal places are set by the values of the parameters FieldWidth and DecP.

The absolute (positive) value of FieldWidth determines the length of the resulting string, with the numeric characters being aligned to the right within that string. Leading blanks are replaced by zeroes if FieldWidth is negative. 

The parameter DecP may take any value between -2 and 18. Values beyond this range are ignored. If DecP takes a negative value, a string using exponential notation is created. For DecP = -2 a special conversion mode is activated which ensures to output only 2 digits for the exponent. In this case a possible overflow of the output format (i.e. for exponents larger than 99) is indicated by creating a string which consists of all asterisks.

Example: The statement OutText (strff(x,10,3)); displays the value of x on the graphics screen using a field width of ten characters and three decimal places. The resulting string is aligned to the right.

Note: The function strff replaces the old function strf of unit MATH1. While strf is still available in MATH1 (for compatibility reasons) it is no longer supported. You should thus use strff for future developments.

Example: This function is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): cluster, covar, curvefit, geodata, periosys, rasterlabel, rctstspd, simplepca, sortarray



Last Update: 2023-Feb-06