p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: alternates to <>


Message #1 by "Jacobson, John" <jacobs35@c...> on Mon, 9 Apr 2001 15:58:52 -0400
Hello Alex,

In VBScript the result of a len(NULL) is NULL and the evaluation of if
NULL>0 then yeilds NULL which is treated according to the reference as a
false.  Maybe I've been getting away with something?  Do you have some code
that can show me the failure you describe...

John

----- Original Message -----
> Subject: RE: alternates to <>
> From: "Alex Shiell, ITS, EC, SE" <alex.shiell@s...>
> Date: Thu, 12 Apr 2001 11:46:24 +0100
> X-Message-Number: 3
>
> if its null then this will fail
>
> even if you do
>
> if isNull(value) or (len(value)>0) then...
>
> it still fails when it tries to evaluate len
>
> i use this function to turn nulls into empty strings
>
> function safeNull(sVal)
> if isNull(sVal) then
> safeNull = ""
> else
> safeNull = sVal
> end if
> end function
>
> then you can happlily do
>
> if (len(safeNull(value))>0) then
>
>
> -----Original Message-----
> From: John Wicks [mailto:j_wicks@p...]
> Sent: Thursday, April 12, 2001 11:19 AM
> To: Code Clinic
> Cc: jacobs35@c...
> Subject: Re: alternates to <>
>
>
> If you're just checking for NULL or empty strings I like to use ...  if
> (len(value)>0) then
>
> John
> ----- Original Message -----
> > From: Jacobson, John [mailto:jacobs35@c...]
> > Sent: Monday, April 09, 2001 3:59 PM
> > To: Code Clinic
> > Subject: alternates to <>
> >
> >
> > Hello All
> >
> > Ive run into a bit of a snag which i think ive properly diagnosed, but
> dont
> > have a cure ;)
> >
> > I can get <> to work just fine for looking for things not equal to a
> numeric
> > value, but it dosent seem to like to work when looking at text strings.
> >
> > what are the alternates i can try?
> >
> > thanks
> >
> > /john
>
>
> _______________________________________________________________________
> Scottish Enterprise Network
> http://www.scottish-enterprise.com
>
> ----------------------------------------------------------------------
>
> Subject: Re: alternates to <>
> From: "Ken Schaefer" <ken@a...>
> Date: Thu, 12 Apr 2001 22:21:36 +1000
> X-Message-Number: 4
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : even if you do
> :
> : if isNull(value) or (len(value)>0) then...
> :
> : it still fails when it tries to evaluate len
> : i use this function to turn nulls into empty strings
> :
> : function safeNull(sVal)
> : if isNull(sVal) then
> : safeNull = ""
> : else
> : safeNull = sVal
> : end if
> : end function
> :
> : then you can happlily do
> : if (len(safeNull(value))>0) then
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Or you could just concatenate a ZLS (""), which would force an implicit
> conversion of null to string, enabling either a Len() evaluation, or a
> straight comparision with ""
>
> If Len(sNull & "") = 0 then
>     ' Null or ZLS
> End if
>
> -OR-
>
> If sNull & "" = "" then
>     ' Null or ZLS
> End if
>
> Cheers
> Ken
>
>
>
> ----------------------------------------------------------------------
>
> Subject: RE: alternates to <>
> From: "Ian Cox" <ian_cox2001@h...>
> Date: Thu, 12 Apr 2001 14:34:22
> X-Message-Number: 5
>
> > if its null then this will fail
> >
> > even if you do
> >
> > if isNull(value) or (len(value)>0) then...
> >
> > it still fails when it tries to evaluate len
> >
> You are correct.
> This is because len(null) will return null because it is meaningless and
> anything or'ed with a null will return null (in fact any boolean function
> involving null will necessarily return null (hence the existence of IsNull
> ())).
> Cheers
> Ian
>
>

  Return to Index