Are you sure there aren't other characters in the string (spaces, etc.?).
Why not just put a: say value Before the point you get the error to see exactly what is causing it?
This part in the code ensures for the full 100% that the contents of Value consists of the characters 0 - 9 and '.''s:
Pos = VERIFY(Value, '0123456789.')/* Pos becomes the index of the first character NOT contained in '012345678.' */
DO WHILE Pos > 0
Value = DELSTR(Value, Pos, 1) /* Delete that character */
Pos = VERIFY(Value, '0123456789.') /* Look for another such character */
END
So there are *NO* other characters then the allowed ones.
But I found this odd behaviour:
In = 12a34 --> Out = 1234 --> DATATYPE = NUM
In = 22...45.7 -->Out = 22.457 --> DATATYPE = NUM
Now the odd one:
In = "34,56" --> Out = 34.56 --> DATATYPE = CHAR
In my opening post you can see that comma's are TRANSLATEd to points by this (the first) line:
Value = TRANSLATE(Value, '.', ',') /* All (decimal) comma's turn into decimal points */
The final part of the code presented:
Pos = LASTPOS('.', Value) /* Find the last occurrence of '.'in Value */
DO WHILE INDEX(Value, '.') < Pos /* Loop if there is more than ONE '.'in Value */
Value = DELSTR(Value, Pos, 1) /* Delete that redundant decimal-point */
Pos = LASTPOS('.', Value) /* Again, look for another instance of '.' */
END
...ensures that there is only *ONE* '.' allowed.
As I said before, IMHO, a string of '12.34' should yield NUMERIC.
I found the culprit to be in use of the comma. ANY string containing a comma will NEVER turn into a string that yields NUMERIC! Whatever processing you do to that string! Even copying it to another variable, when it LOOKS NUMERIC, will turn that string in the other variable into DATATYPE = CHAR!
Strange, but it is.
I also found a way, albeit a very, very elaborate one, to overcome this situation. I'll post it later on, as I have to make somefinal tests first.
May arise the question of why putting in a comma in a numerical field in the first place. This question arises mainly in the Anglo-Saxon part of the world. 10 million currency units minus 1 cent is written this way:
Anglo-Saxon style: 9,999,999.99
Rest of the world: 9.999.999,99
As I am living in a country that is part of the latter group, decimals are separated from integers by a comma. Hence a numerical string can contain a comma. Hence I've got a (now minor) problem...
Off to the testing,
Jettah