Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function empty() and null value
Message
 
 
To
27/06/2011 10:48:42
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01516146
Message ID:
01516249
Views:
50
You are correct that this function can be used on any other type as well. In fact I found out this morning that I need to apply it to other type fields. This is one of the work I have to do when moving from VFP to SQL Server, search and change how the program "deals" with NULLs. I rarely used NULLs in VFP application whereas in SQL Server this value is used a lot.
Thank you.

>I think that is appropriate. I did something similar, calling my function EmptyOrNull() - except I didn't go back and review old code systematically.
>
>Note that the function can be simplified as follows:
>
>
>Function MyEmpty(txValue)
>return empty(txValue) or isnull(txValue)
>
>
>Note, also, that it works for any date type - that's why I renamed the variable.
>
>>Hi,
>>
>>When using SQL Server and allowing NULL in empty dates I came across a small issue where EMPTY( date_field) returns .F. when the entry in date_field is NULL. And this of course breaks a lot of code where the program relied on the date field being empty. I am thinking of creating a simple function like this:
>>
>>Function MyEmpty
>>lparameter tDate
>>if empty( tDate) or isnull( tDate)
>>   return .T.
>>else
>>  return .F.
>>endif 
>>
>>
>>And replace everywhere in the program where I use
>>
>>if EMPTY( date_field ) 
>>
>>with
>>
>>if MyEmpty( date_field )
>>
>>
>>Can anybody see a potential problem with the above approach? TIA.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform