At 18:22 +0200 29/9/04, Frank Heckenbach wrote:
So my proposal is to add (now or later):
function String2Num(???) (const s: String; var n: <numeric type>): Boolean;
Comments?
Isn't that just a utility function? I suspect that sort of thing belongs more in a utility unit that users can include if they desire. Especially since there are hundreds of ways of converting a string to a number and the requirements change depending on the usage. For example:
Do you strip spaces? What decimal separator do you use (".", "," or " " (space))? What thousand separator do you allow if any (".", "," or " " (space), "'", none)? What about stripping a currency symbol? What about supporting exponent symbols like K, M, G, T? Metric or Computer (1024) multipliers? What about hex, octal, binary support? And the ability to specify a default base?
And so on.
In my code, I have about half a dozen different String2Num functions and I'm not all that serious about internationalization and hardly ever let users enter numbers directly.
Enjoy, Peter.