[thelist] Classic ASP: Someone else's code

Phil Turmel philip at turmel.org
Tue Nov 22 12:07:49 CST 2005


Casey wrote:
> What exactly is going on here:
> 
> if trim(Contact_First_x) & "" <> "" AND trim(Contact_Last_x) & "" <> "" then
> 
> In case it's not clear in the email:  "" <> ""  which is: double-quote 
> double-quote <> double-quote double-quote
> 
> I'm not at all understanding the logic of this statement.... anyone?
> 
> Casey 
> 
Casey,

This is a common shortcut to deal with null or empty values as if they 
are zero-length strings.  The above if statement is true if both first 
and last names are null, empty, whitespace, or zero-length.

For most operators in ASP, VB, etc., any use of NULL falls through as 
NULL to the result.  But concatenation is treated differently:  Null 
becomes "".

Whenever I do this, I prefer the concatenation inside the trim for clarity:

trim(Contact_First_x & "") <> "" AND trim(Contact_Last_x & "") <> ""

HTH,

Phil




More information about the thelist mailing list