Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verify if a field already exists in a table
Message
 
To
03/08/2007 18:04:44
Felix Serra
Campus Management Corp.
Miami, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01238247
Message ID:
01245912
Views:
34
>Fred Taylor's solution is what I use. It's short, clean, and to the point. No need to complicate or write useless code if this does the very same thing.

In my case, and keep in mind that is just my personal preference I am not saying your code is useless, I try never to use a generic function to get a particular result when there is a function which has been written specifically to address that particular need, in this case the Field() function specifically addresses the original poster question so I would use it even if Type returned the correct result always, which is not the case by the way, there is a thread somewhere but I think the gist of it is something like this (I think there are better examples in the aforementioned thread)
create cursor yourtable (yourfield I)

yourtable	= Createobject('Empty')
Addproperty(yourtable, 'fieldname', 'Object')

? TYPE("yourtable.fieldname") <> "U", Empty(Field('fieldName'))
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform