Angle2Str Routines

Unit
QESBPCSConvert

Overloaded Variants
Function Angle2Str(const Angle: Extended; const DecimalPlaces: Byte = 2): string;
Function Angle2Str(const Degrees, Minutes: Integer; const Seconds: Extended; const Sign: Shortint = 1; const DecimalPlaces: Byte = 2): string;

Declaration
Function Angle2Str(const Angle: Extended; const DecimalPlaces: Byte = 2): string;

Implementation

function Angle2Str (const Angle: Extended; const DecimalPlaces: Byte = 2): string;
var
     Degrees, Minutes: Integer;
     Seconds: Extended;
     Sign: Shortint;
begin
     Deg2DMS (Angle, Degrees, Minutes, Seconds, Sign);
     Result := Angle2Str (Degrees, Minutes, Seconds, Sign);
End;

Declaration
Function Angle2Str(const Degrees, Minutes: Integer; const Seconds: Extended; const Sign: Shortint = 1; const DecimalPlaces: Byte = 2): string;

Implementation

function Angle2Str (const Degrees, Minutes: Integer; const Seconds: Extended;
     const Sign: Shortint = 1; const DecimalPlaces: Byte = 2): string;
begin
     if (Minutes < 0) or (Minutes > 59) then
          raise EConvertError.Create (rsInvalidAngle);

     if (Seconds < 0) or (Seconds >= 60) then
          raise EConvertError.Create (rsInvalidAngle);

     Result := Int2EStr (Degrees) + ESBDegreeStr
          + Int2EStr (Minutes) + ESBMinuteStr
          + Float2EStr (Seconds, DecimalPlaces) + ESBSecondStr;

     if (Degrees = 0) and (Sign = -1) then
          Result := '-' + Result;
End;


HTML generated by Time2HELP
http://www.time2help.com