lotusscript

Does the Lotusscript if statement short circuit?


Quick one: Does anyone know if the Lotusscript if statement short circuits? Nothing appears to be written in the documentation.

E.g. if doc.HasItem("MyField") test is false, the doc.MyField(0)=... test is not performed.

if doc.HasItem("MyField") and doc.MyField(0)<>"" then ...

Solution

  • The if statement in LotusScript definitvely doesn't short circuit. The complete statement is evaluated and then the decision is made. This sometimes is very annoying e.g when you want to do something like:

    If doc.HasItem( "SomeNumber" ) and doc.GetItemValue( "SomeNumber" )(0) > 100 Then
    

    This will throw a "Type mismatch" for documents that do not have the item "SomeNumber" as the comparision is made although the first statement is already false...