Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Verify if a field already exists in a table
Message
From
04/08/2007 10:24:57
Mike Yearwood
Toronto, Ontario, Canada
 
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:
01245951
Views:
31
>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)

I'd like to agree with that but, it's never that simple. Field didn't always accept the field name. Hence the use of type etc. In fact the sample code for FIELD() even now does not show that it accepts anything but a number. ;) A UDF is supposed to encapsulte the complexities. An IsField UDF does the job while allowing our code to improve while never needing to go back and replace all TYPE() with FIELD().

Further, the penchant to write a formula off the cuff yields code that is unreable. Even the formula "TYPE('something')" cannot be deciphered as easily as "IsField('something')".
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform