Hi shakeshuck,
There are some options here.
eC being a C super-set, anything C will work (e.g. strtod(), strtol()).
The current eC way is probably calling OnGetDataFromString() on your numeric type:
- Code: Select all
float x;
if(a.OnGetDataFromString(string))
PrintLn("Successfully parsed float value: ", x);
This will however return success even if there are further characters after a numeric value.
Use strtol() or strtod() for finer control, which returns a pointer saying where the parsing ended.
You may also want to look into using a SavingDataBox with a data type set to float or double, which will automatically convert to numbers and reject invalid input.
Regards,
-Jerome