Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vartype() type works different for hyperlink?
Message
De
07/07/2003 22:41:59
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00807623
Message ID:
00807812
Vues:
21
I hear what you and Sergey are saying, but with the exception of reserved words I have had no problem using Vartype() with objects. I just have to make sure that the object exists first. If there is any doubt that the object exists then I use type(), but once I've determined that the object exists, I don't see the point of not using Vartype() for further tests.
local loDoc
loDoc = createobject('myClass')
if type('loDoc.NAME') = 'C'
  ? Vartype(loDoc.Test)          && U
  ? Vartype(loDoc.BaseClass)     && C
  ? Vartype(loDoc.ColorSource)   && N
  etc...
endif
>
clear all
>? vartype( testmemvar ) && U
>testmemvar = "hi"
>? vartype( testmemvar ) && C
>testmemvar = 0
>? vartype( testmemvar ) && N
>testmemvar = createobject( "form" )
>? vartype( testmemvar ) && O
>
>
>Bottom line vartype() is designed to work for memvars. It is not designed to work for object properties as you have seen from the errors thrown and the unpredictable results. Use type() or pemstatus() to test for object properties.
>
>>I'm using VFP 7.0
>>
>>goHPL = CreateObject('HyperLink')
>>? vartype( goHPL )           && returns 'O'
>>? vartype( goHPL.test )      && returns 'U'
>>? vartype( goHPL.Left )      && Error "Property Left is not Found"
>>
>>Is this the say it's supposed to work?
Bill Morris
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform