Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this a Y2K problem?
Message
De
03/01/2000 13:41:24
 
 
À
03/01/2000 12:45:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00311693
Message ID:
00311815
Vues:
18
>>>You're running into the trap of misusing SYS(2015) - and then take a look at VFP's rules for valid name formation. VFP's parser expects names to start with an _ or alpha character; you can force past that with name expansion. Why it changed may be involved with how SYS(2015) operates - the value created is dependent on date and time, and as a result, it's probably forming the value differently because you crossed some arbitrary value. Look at SYS(2015) - it doew not return a valid name in the last 8 bytes of the 10 character string - it returns a valid 10 byte name. If your system can't deal with an LFN reliably, the substring of SYS(2015) in and of itself is not a valid means of forming a name.
>>>
>>>This is a case where you got away with slop in the past and it bit you squarely on the buttocks. Be glad it didn't grab a more anterior location.
>>
>>
>>
>>BTW, for your information, those lines of code were taken from a code sample posted by a big-time well-known foxpro programmer. I didn't know why he/she was using the SUBSTR, but I figured he/she knew more than me.
>
>Hmmm...sounds like a personal problem. In all probability, the substring was used because they wanted to use the approach to deploy in environments where LFNs might not be supported, and as a result, they used substring to extract a string of 8 bytes length that was -probably- unique and legal. If you read the VFP docs for SYS(2015), you find:

>
>Returns a unique 10-character procedure name that begins with an underscore followed by a combination of letters and numbers.
>
>Syntax
>
>SYS(2015)
>
>Returns
>
>Character
>
>Remarks
>
>SYS(2015) can be used to create unique procedure or function names.>
>The name that SYS(2015) returns is created from the system date and system time. Calling SYS(2015) more than once during the same millisecond interval will return a unique character string.

>
>The key clues are provided here. The unique name is 10 characters long, starting with an _ character. This makes sure that the name formed is legal.
>
>It does not guarentee that substrings will be unique. It does not guarentee that substrings will give a valid name. It tells you that the date and time affect the string formed. It tells you that some characters in the string other than the first character may be numeric, which, in conjunction with VFP's name rules, would result in an invalid name, which is one reason the prefix character of _ is used.
>
>The fact that a "big-time well-known foxpro programmer" did something stupid is not a major surprise. Rep does little to protect you from making mistakes.

Hi Ed,

Actually I think this SUBSTR() issue with SYS(2015) was originally recommended by MS and may still be found in the MSKB. Like John, I used it cause MS said to, :-) until it bit me November a year ago. Went thru and fixed the occurrences to use all 10 characters and the problem was rectified.
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform