If I have a table with a field defined as N(5,1). I would expect the field to be able to contain a max value of 999.9. Why will FoxPro allow me to "replace" the field with 99999 but only allow 999.9 in a browse.
Well the simple answer is "because that's the way dBaseII did it!".
Unlike some langages (COBOL and FORTRAN) come to mind, the number of decimals in xBase is not really fixed or "implied", it's actually based on how where the decimal point is stored in the field. And while you can cheat with a replace, the Browse or Grid use the table definition to know where the decimal is supposed to be.
It appears to me that FoxPro thinks its a 5 position numeric field that can possibly store 1 decimal.
My real problem is this field is in a cursor that is updating a SQL table with a numeric field defined as 4,1 and when I do the SQL replace, SQL gives me an error. I would expect FoxPro to give me the error before SQL.
You can always build your own validation routine using AFIELDS() and allow for a max allowed value of VAL(REPLICATE([9],FieldLen-(DecimalsN+1))+[.]+REPLICATE([9],DecimalsN)) and a min allowed value of VAL([-]+REPLICATE([9],FieldLen-(DecimalsN+2))+[.]+REPLICATE([9],DecimalsN)) for numerica data types.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.