Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's up with the PADL?
Message
From
11/10/2005 01:21:52
 
 
To
11/10/2005 00:54:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01057840
Message ID:
01057845
Views:
9
>A method received a primary key like this:
>
>
>PARAMETER tnNumero
>
>
>That is an integer coming in from the table.
>
>The next line is using a PADL syntax:
>
>
>ERASE (gcClientFat+'Images\SchoolPicture\'+PADL(tnNumero,6,'0')+'.jpg')
>
>
>Instead of being something like ..\000005.jpg, it gives something like ..\005.00.jpg. This is not the first time this is happening. I have seen that since VFP 9 at several occasions where I am using PADL(). The only way to be sure this will be properly interpreted, I have to do this:
>
>
>ERASE (gcClientFat+'Images\SchoolPicture\'+PADL(INT(tnNumero),6,'0')+'.jpg')
>
>
>How can I resolve the issue?

Hmm, interesting. I didn't know you could use PADL() with a general expression, I thought it had to be a string. So, I've always done something like
... + PADL( LTRIM( STR( tnNumero ) ), 6, "0" )
I think what you're seeing must be related to the fact that tnNumero cannot be an integer, as that is not a VFP data type (only a field type), so it's coming across as a numeric, with a value slightly different from what you expect. Maybe PADL() has trouble with a long string like 5.0000000000001, perhaps internally it tries to add another 6 sig figs and loses precision, or ??

You'll need to be careful with your code, if the value comes across as 4.999999999999 you'll be deleting using a value of 4 instead of 5. You might actually want to use
PADL( INT( ROUND( tnNumero, 0 ) ), 6, "0" )
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform