| Str2Single Function | 
Unit
QESBPCSConvert
Declaration
Function Str2Single(const S: string): Single;
Description
Removes Thousand Separators if they are present as well as any leading or trailing white spaces (ie <= #32). If Number is Valid but out of Range then MaxSingle will be returned for a greater value and -MaxSingle for a lesser value. Non-numeric will return 0 unless you set ESBRaiseFloatError to true.
Also ignores Percentage Signs (%).
| Parameters | 
| S | the String to process | 
Category
String/Float Conversion RoutinesImplementation
 
| function Str2Single (const S: string): Single;
var
     X: Extended;
begin
     X := Str2Float (S);
     if X > MaxSingle then // Check with in boundaries
          Result := MaxSingle
     else if X < -MaxSingle then
          Result := -MaxSingle
     else
          Result := X; // Return Value
End; | 
|  |