Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a VFP function to...
Message
De
28/06/2006 13:22:16
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
28/06/2006 12:34:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01132372
Message ID:
01132508
Vues:
19
>>>>>>
>>>>>>LOCAL lcControl
>>>>>>lcControl = IIF(UPPER(LEFT(Object.ControlSource,2)) == [M.],SUSBTR(Object.ControlSource,3),Object.ControlSource)
>>>>>>DO CASE
>>>>>>   CASE TYPE([m.]+lcControl) == [U] AND; && Not a memory variable
>>>>>>        TYPE(lcControl)      #  [U]
>>>>>>        REPLACE (lcControl) WITH WITH ltNewDateTime
>>>>>>   CASE TYPE(lcControl)      == [C] && Memory variable
>>>>>>        STORE ltNewDateTime TO (lcControl)
>>>>>>OTHERWISE
>>>>>>        *** something wrong
>>>>>>ENDCASE
>>>>>>
>>>>>>(not tested for all occasions)
>>>>>
>>>>>I guess you ment to use VARTYPE() and not TYPE(), with TYPE() you must enclose the variable names with apostrophs. (I know that you know that!)
>>>>
>>>>PFMJI, but he's right - lcControl contains the name of the variable or field. Vartype(lcControl) would always return "C", while type(lcControl) returns the type of the expression it contains. Hence, this should read
>>>>
>>>>
>>>>LOCAL lcControl
>>>>lcControl = IIF(UPPER(LEFT(Object.ControlSource,2)) == [M.],SUSBTR(Object.ControlSource,3),Object.ControlSource)
>>>>DO CASE
>>>>   CASE TYPE([m.]+lcControl) == [U] AND; && Not a memory variable
>>>>        TYPE(lcControl)      =  [T]    && a datetime field
>>>>        REPLACE (lcControl) WITH WITH ltNewDateTime
>>>>   CASE TYPE(lcControl)      == [T] && datetime Memory variable
>>>>        STORE ltNewDateTime TO (lcControl)
>>>>OTHERWISE
>>>>        *** something wrong
>>>>ENDCASE
>>>>
>>>Sorry, but you are wrong, and I am right! :-)
>>>?vartype(sometextfield) && C
>>>?vartype(somenumericfield) && N
>>>?type(somenumericfield) && Raises an error
>>>?type(somedatetimefield) && Raises an error
>>>?type("somedatetimefield") && T
>>>?vartype(somedatetimefield) && T
>>>?vartype("somedatetimefield") && C because "somedatetimefield" is text
>>
>>Tore,
>>Controlsource already have the quotes:)
>>Cetin
>
>A-ha, I never really analyzed that first line. Where is that hole in the ground when you really need it? :-)

You can write your own drilling code... need a builder? :)

I think we got our point across - the moment you have a variable's name (or a field name) in another variable, and start playing with type() and vartype(), the things become very, ahem, interesting. So, yes, just a single oversight (i.e. is this the variable, or a variable holding the name of another variable) can lead to geological results.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform