Groups | Blog | Home
all groups > dotnet jscript > november 2004 >

dotnet jscript : Help with IF and OR Clause



John Cosmas
11/23/2004 8:26:36 PM
I have a field containing a Date value. Unfortunately, it keeps returning a
NULL. I need the NULL evaluated. Please fix this statement

if(_values != null) || (length(_values) != 0)

TIA
John Cosmas

Simone Massaro
12/2/2004 10:56:47 AM
the OR condition evaluates both statement: this means that you are trying to
access the _value even when it is null. This would cause a crash.
instead of an OR condition you need to use an AND condition:
if (_values != null) && (length(_values) != 0)

The end condition use shortcut evaluation, which means that it will evaluate
the second condition only if the first is verified, thus _value will never
be accessed if it is null and it will not crash
- Simone

AddThis Social Bookmark Button