Using If...Then...Else Statements

You can use the If...Then...Else statement to run a specific statement or a block of statements, depending on the value of a condition. If...Then...Else statements can be nested to as many levels as you need. However, for readability, you may want to use a Select Case statement rather than multiple levels of nested If...Then...Else statements.

Running statements if a condition is true

To run statements when a condition is True, use the following syntax of the If...Then... statement. This syntax includes the End If statement.

If s4con_no_mortgagees > "1" Then
 Rem Redemption address 2
 CreateParty ("11C4D - Lenders","C4DG")
 SetVariable ("s5con_roll2","Enter the second charge roll number","",no)
End If

Running certain statements if a condition is true and running others if it's false

Use an If...Then...Else statement to define two blocks of executable statements: one block runs if the condition is True, the other block runs if the condition is False.

If dba_own_client = "Yes" Then
PostTime ("l",6,"",no)
Else
 PostTime ("l",6,"",no)
End If

Testing a second condition if the first condition is false

You can add ElseIf statements to an If...Then...Else statement to test a second condition if the first condition is False. For example, the following function procedure computes a bonus based on job classification. The statement following the Else statement runs if the conditions in all of the If and ElseIf statements are False.

If z2con_reg_unreg = "Yes" Then
 SetVariable ("s1con_title_no","Please enter the title number","",no)
Else
 If az1con_next = Yes Then
 Next ("PDMMA",0,"snextprc","Default",no,no,"Please carry out an index map search on this unregistered land","C41",3,3)
 End If
End If