Int2CEStr Routines |
Unit
QESBPCSConvert
Overloaded Variants |
Function Int2CEStr(const L: LongInt): string; |
Function Int2CEStr(const L: Int64): string; |
Declaration
Function Int2CEStr(const L: LongInt): string;
Description
ESBNumPosSign controls whether a '+' Sign appears at the beginning for positive Integers. ESBBlankWhenZero can be set to True to have Zero returned as an Empty string.
Parameters |
L | Value to Convert to String. |
Category
String/Integer Conversion RoutinesImplementation
function Int2CEStr (const L: LongInt): string; var LS, L2, I: Integer; Temp: string; begin if ESBBlankWhenZero and (L = 0) then begin Result := ''; Exit; end; try FmtStr (Result, '%d', [abs (L)]); // Format the string if L = Low (LongInt) then Result := RightAfterStr (Result, 1); LS := Length (Result); L2 := (LS - 1) div 3; // Number of 'groups of three' Temp := ''; for I := 1 to L2 do Temp := ThousandSeparator + Copy (Result, LS - 3 * I + 1, 3) + Temp; Result := Copy (Result, 1, (LS - 1) mod 3 + 1) + Temp; if L < 0 then // Add Sign if necessary Result := '-' + Result else if (L > 0) and ESBNumPosSign then Result := '+' + Result; except Result := '' end; End; |
Declaration
Function Int2CEStr(const L: Int64): string;Implementation
function Int2CEStr (const L: Int64): string; var LS, L2, I: Integer; Temp: string; begin if ESBBlankWhenZero and (L = 0) then begin Result := ''; Exit; end; try FmtStr (Result, '%d', [abs (L)]); // Format the string if L = Low (Int64) then Result := RightAfterStr (Result, 1); LS := Length (Result); L2 := (LS - 1) div 3; // Number of 'groups of three' Temp := ''; for I := 1 to L2 do Temp := ThousandSeparator + Copy (Result, LS - 3 * I + 1, 3) + Temp; Result := Copy (Result, 1, (LS - 1) mod 3 + 1) + Temp; if L < 0 then // Add Sign if necessary Result := '-' + Result else if (L > 0) and ESBNumPosSign then Result := '+' + Result; except Result := '' end; End; |
|