i have done some testing, and it appears that a conditional like:
if false and true and false
would evaluate all, even if at the first false it should return “false”.
Why is this?
i have done some testing, and it appears that a conditional like:
if false and true and false
would evaluate all, even if at the first false it should return “false”.
Why is this?
Subject: If Evaluates All? Even if first condition fails?
can you post the actual code logic
Subject: RE: If Evaluates All? Even if first condition fails?
If (Not (auxdoc Is Nothing)) And (auxdoc.XX(0) = XX) And (auxdoc.YY(0) = YY) And (auxdoc.GetFirstItem(“ZZ”).DateTimeValue.LsLocaltime = cdoc.GetFirstItem(“ZZ”).DateTimeValue.LsLocaltime) Thenend if
it would return an error saying that auxdoc is nothing, instead of stoping aht the “(not (auxdoc is nothing))” evaluation (false).
Subject: RE: If Evaluates All? Even if first condition fails?
Try nesting.
If Not auxdoc Is Nothing Then ’ means auxdoc is a document
If (auxdoc.XX(0) = XX) And (auxdoc.YY(0) = YY) And (auxdoc.GetFirstItem(“ZZ”).DateTimeValue.LsLocaltime = cdoc.GetFirstItem(“ZZ”).DateTimeValue.LsLocaltime) Then
’ some code you want to execute goes in here
End If
End If
Shawn
Subject: RE: If Evaluates All? Even if first condition fails?
that is how i fixed it, but i shouldn’t.
Notes should stop after the first (Not (auxdoc Is Nothing)).
Subject: RE: If Evaluates All? Even if first condition fails?
It all depends on the compiler. The LS compiler probably isn’t sophisticated enough to isolate that code in a way that it can recognize it as an atomic execute-me-first insruction.
Subject: RE: If Evaluates All? Even if first condition fails?
It is defined as not supporting truncated conditionals. Some compilers/languages use truncated conditions (e.g., Java and C++), while others do not. It isn’t an error, as such, although I agree that I wish they were supported, as the nesting is annoying.
Subject: LS evaluates whole expression…
…while java stops at the first unsatisfied constraint.Use nesting as suggested.