They are actually derived from some work I have done in LibFredo6 (in module Traductor).
I enclosed the methods in a module called ArithmeString, which you can of course change if you enclose some of this code in your script.
- string_to_integer --> parse a string as an integer
- string_to_integer_formula --> parse a string as a formula evaluating as an integer
- string_to_float --> parse a string as a float
- string_to_float_formula --> parse a string as a formula evaluating as a float
- string_to_length --> parse a string as a length
- string_to_length_formula --> parse a string as a formula evaluating as a length
Note that all methods accepts the "." or the "," as valid decimal delimiter, regardless of the underlying locale of the operating system and SU version language.
All the formula methods accepts parentheses to manage more complex calculations.
For lengths, there is a logical order to respect for specifying units and numbers (ex: 2cm * 4, NOT 4 * 2cm)
The attached file contains the methods with some additional comments
Fredo