Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric overflow issue
Message
 
To
03/12/2001 03:41:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00588052
Message ID:
00588936
Views:
38
>>>>I am trying to do a [replace all] for cField = ***** (Numeric overflow) but I get a error cause ***** has no quotes and isn't a number
>>>
>>>... for cField>val(replicate('9',fsize('cField')))
>>>
>>>bye
>>
>>This wont work if the field has decimals, ie N(10,3)
>
>You're right.
>
>>
>>PROCEDURE maxval
>>LPARAMETERS size, dec
>>LOCAL cNum
>>cNum = REPLICATE('9', dec)
>>cNum = "." + m.cNum
>>cNum = REPLICATE('9', m.Size - (m.dec + 1)) + m.cNum
>>RETURN VAL(m.cNum)
>>
>
>Since size and dec must be passed as arguments to the function, this is hardly a general approach. In fact, knowing that information, it would be simpler to hardcode the value in the scope expression (like Caroline suggested).
>
>Strangely, VFP seems to not have a function to give you the precision of a numeric field, or am I missing something?
>
>bye

AFIELDS gives some info, and there are a few more that I cant think of off the top of my head.
But by passing the Size and Dec you can use this for more then just a field of an opened database. Making it a general approach.
If I was doing something with checking for overflows, I would no doubt do an AFIELDS()
then Loop through that, take the size and precision, pass it into the above code, and then replace for myField > maxVal, though it isnt the best way to do the replacement either, replace for locks the entire table if im not mistaken.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform