Unfortunately, the PowerScript programming language doesn't support the short-circuit evaluation of Boolean expressions - the evaluation is always "long-circuit" . Let's suppose we have Boolean functions uf_is_bird() and uf_is_dinosaur(); the first one is very lightweight and quick (just as a bird), but the second is very heavy and slow (just as a dinosaur). If you have come to PowerBuilder from a programming language which supports the short-circuit evaluation (and almost all the languages support it!), you can mistakenly write:
You can suppose, that uf_is_dinosaur() will not be called if uf_is_bird() has returned true, but you are wrong: uf_is_dinosaur() will be executed ALWAYS. So, express yourself in one of the following ways:
if uf_is_bird() then return true if uf_is_dinosaur() then return true return false
It was an OR relation, but the same problem exists with an AND. In the following example, the condition ll_row > 0 will not protect against failure when ll_row = 0 (as a Java or C# developer could think):
lb_from_usa = false if ll_row > 0 then lb_from_usa = (dw_addr.object.country[ll_row] = "US")
Remember about that when you are trying to make you code safer using the IsValid() function. The following example, written in the Java/C# style, is dangerous - if the object has not been created, you will get a run-time error: