The End If token is used to mark the end of an If conditional block. Every If statement must have a corresponding End If to define where the conditional structure terminates. The End If statement closes the entire If-Elif-Else chain and is required regardless of whether Elif or Else clauses are present.
The short syntax structure uses the words END IF:
IF CONDITION
STATEMENTS
END IFThe long syntax structure uses the words END IF:
IF CONDITION
STATEMENTS
END IFEnd If is required to close every If statement.
NEW INT age = 20
IF age >= 18
PRINTLN "You are an adult"
END IF
PRINTLN "Program continues"
// Displays "You are an adult" and "Program continues"NEW INT score = 85
IF score >= 90
PRINTLN "Grade: A"
ELSE
PRINTLN "Grade: B or below"
END IF
PRINTLN "Grading complete"
// Displays "Grade: B or below" and "Grading complete"NEW FLOAT temperature = 75.0
IF temperature >= 90.0
PRINTLN "Hot"
ELIF temperature >= 70.0
PRINTLN "Warm"
ELSE
PRINTLN "Cool"
END IF
PRINTLN "Temperature check complete"
// Displays "Warm" and "Temperature check complete"NEW INT x = 5
IF x > 10
PRINTLN "x is large"
END IF
PRINTLN "After conditional"
PRINTLN "Program running"
NEW INT y = 20
// All statements after END IF execute normallyEnd If terminates the entire conditional structure, including all If, Elif, and Else clauses.
NEW INT day = 3
IF day == 1
PRINTLN "Monday"
ELIF day == 2
PRINTLN "Tuesday"
ELIF day == 3
PRINTLN "Wednesday"
ELIF day == 4
PRINTLN "Thursday"
END IF
PRINTLN "Day processed"
// Displays "Wednesday" and "Day processed"NEW INT score = 72
IF score >= 90
PRINTLN "Grade: A"
ELIF score >= 80
PRINTLN "Grade: B"
ELIF score >= 70
PRINTLN "Grade: C"
ELIF score >= 60
PRINTLN "Grade: D"
ELSE
PRINTLN "Grade: F"
END IF
PRINTLN "Report card generated"
// Displays "Grade: C" and "Report card generated"NEW INT x = 15
NEW INT y = 20
IF x > 10
PRINTLN "x is greater than 10"
END IF
IF y > 10
PRINTLN "y is greater than 10"
END IF
// Both conditionals are independent
// Displays both messagesEach If statement requires its own End If, including nested conditionals.
NEW INT age = 25
NEW BOOL hasLicense = TRUE
IF age >= 18
IF hasLicense == TRUE
PRINTLN "Can drive"
ELSE
PRINTLN "Need license"
END IF
ELSE
PRINTLN "Too young"
END IF
PRINTLN "Check complete"
// Inner IF needs END IF, outer IF needs END IFNEW INT level = 2
NEW INT points = 150
IF level >= 1
IF level >= 2
IF points >= 100
PRINTLN "Advanced player"
END IF
END IF
END IF
PRINTLN "Player status checked"
// Three IF statements require three END IF statementsNEW STR userType = "premium"
NEW INT accountAge = 15
IF userType == "premium"
IF accountAge >= 12
PRINTLN "Long-term premium member"
ELIF accountAge >= 6
PRINTLN "Established premium member"
ELSE
PRINTLN "New premium member"
END IF
ELIF userType == "standard"
PRINTLN "Standard member"
END IF
PRINTLN "Member status complete"
// Inner IF-ELIF-ELSE needs END IF
// Outer IF-ELIF needs END IFNEW INT a = 10
NEW INT b = 20
IF a > 5
PRINTLN "a is greater than 5"
IF b > 15
PRINTLN "b is greater than 15"
IF ( a + b ) > 25
PRINTLN "Sum is greater than 25"
END IF
END IF
END IF
PRINTLN "All checks complete"
// Each IF requires its own END IFCode after End If always executes, regardless of which branch was taken in the conditional.
NEW INT value = 5
IF value > 10
PRINTLN "Inside IF block"
ELSE
PRINTLN "Inside ELSE block"
END IF
PRINTLN "This always executes"
// "This always executes" runs regardless of conditionNEW STR status = ""
IF TRUE
SET status = "active"
END IF
PRINTLN "Status: " .. status
// Variables modified inside IF are accessible after END IFNEW INT score = 85
NEW INT bonus = 0
IF score >= 80
SET bonus = 10
END IF
NEW INT finalScore = score + bonus
PRINTLN "Final score: " .. finalScore
// Calculations after END IF use updated valuesNEW INT x = 15
IF x > 10
PRINTLN "Condition met"
END IF
SET x = x + 5
PRINTLN "x is now: " .. x
IF x > 20
PRINTLN "x exceeds 20"
END IF
// Multiple statements and conditionals after END IFIf statements inside loops require End If before the loop can continue to the next iteration.
NEW INT i = 1
WHILE i <= 5
IF ( i % 2 ) == 0
PRINTLN i .. " is even"
ELSE
PRINTLN i .. " is odd"
END IF
SET i = i + 1
END WHILE
// END IF closes the conditional before loop continuesNEW INT num = 1
WHILE num <= 10
IF num < 5
PRINTLN num .. " is low"
END IF
IF num >= 5
PRINTLN num .. " is high"
END IF
SET num = num + 1
END WHILE
// Each IF needs its own END IF within the loopNEW INT i = 1
WHILE i <= 5
IF i > 2
IF i < 5
PRINTLN i .. " is in range"
END IF
END IF
SET i = i + 1
END WHILE
// Nested conditionals each need END IFNEW INT counter = 1
WHILE counter <= 10
IF counter == 5
PRINTLN "Stopping at 5"
BREAK
END IF
PRINTLN "Count: " .. counter
SET counter = counter + 1
END WHILE
// END IF comes before BREAKVariables created or modified before End If remain accessible after End If.
NEW STR result = ""
IF TRUE
SET result = "completed"
END IF
PRINTLN result
// Displays "completed" - variable accessible after END IFNEW INT total = 0
NEW INT count = 0
IF TRUE
SET total = 100
SET count = 5
END IF
NEW INT average = total / count
PRINTLN "Average: " .. average
// Variables updated in IF are used after END IFNEW BOOL hasBonus = TRUE
NEW INT salary = 50000
NEW INT bonus = 0
IF hasBonus == TRUE
SET bonus = 5000
END IF
NEW INT totalPay = salary + bonus
PRINTLN "Total compensation: " .. totalPay
// Displays "Total compensation: 55000"NEW INT age = 25
NEW BOOL validAge = FALSE
IF ( age >= 0 ) && ( age <= 120 )
SET validAge = TRUE
PRINTLN "Age is valid"
ELSE
PRINTLN "Invalid age"
END IF
IF validAge == TRUE
PRINTLN "Processing user data"
END IF
// Second conditional uses result from firstNEW INT score = 85
NEW STR grade = ""
IF score >= 90
SET grade = "A"
ELIF score >= 80
SET grade = "B"
ELIF score >= 70
SET grade = "C"
ELSE
SET grade = "F"
END IF
PRINTLN "Grade assigned: " .. grade
NEW BOOL passed = FALSE
IF grade != "F"
SET passed = TRUE
END IF
IF passed == TRUE
PRINTLN "Student passed the course"
END IF
// Multiple conditionals process sequentiallyNEW STR username = "admin"
NEW STR password = "pass123"
NEW BOOL authenticated = FALSE
IF username == "admin"
PRINTLN "Username verified"
END IF
IF password == "pass123"
PRINTLN "Password verified"
END IF
IF ( username == "admin" ) && ( password == "pass123" )
SET authenticated = TRUE
END IF
IF authenticated == TRUE
PRINTLN "Access granted"
END IF
// Each check completes before next beginsNEW FLOAT balance = 1500.0
NEW STR accountStatus = "active"
IF balance >= 1000.0
SET accountStatus = "premium"
PRINTLN "Upgraded to premium"
END IF
PRINTLN "Current status: " .. accountStatus
NEW FLOAT fee = 0.0
IF accountStatus == "premium"
SET fee = 0.0
ELSE
SET fee = 10.0
END IF
PRINTLN "Monthly fee: $" .. fee
// Status from first IF affects second IFNEW INT errorCode = 404
NEW STR errorMessage = ""
IF errorCode == 404
SET errorMessage = "Not Found"
ELIF errorCode == 500
SET errorMessage = "Server Error"
ELIF errorCode == 403
SET errorMessage = "Forbidden"
ELSE
SET errorMessage = "Unknown Error"
END IF
PRINTLN "Error " .. errorCode .. ": " .. errorMessage
NEW BOOL shouldRetry = FALSE
IF errorCode == 500
SET shouldRetry = TRUE
END IF
IF shouldRetry == TRUE
PRINTLN "Retrying request..."
END IF
// Error handling completes at END IFNEW INT userLevel = 2
NEW INT maxConnections = 10
IF userLevel >= 3
SET maxConnections = 100
ELIF userLevel >= 2
SET maxConnections = 50
ELIF userLevel >= 1
SET maxConnections = 25
END IF
PRINTLN "Max connections: " .. maxConnections
NEW INT timeout = 30
IF userLevel >= 2
SET timeout = 60
END IF
PRINTLN "Timeout: " .. timeout .. " seconds"
// Configuration built step by stepNEW INT basePoints = 100
NEW INT multiplier = 1
NEW INT difficulty = 3
IF difficulty >= 3
SET multiplier = 3
ELIF difficulty >= 2
SET multiplier = 2
END IF
NEW INT totalPoints = basePoints * multiplier
PRINTLN "Points earned: " .. totalPoints
NEW INT bonus = 0
IF totalPoints >= 200
SET bonus = 50
END IF
NEW INT finalPoints = totalPoints + bonus
PRINTLN "Final points: " .. finalPoints
// Points calculated across multiple conditionalsNEW INT x = 5
IF x > 10
PRINTLN "High"
ELIF x > 5
PRINTLN "Medium"
ELSE
PRINTLN "Low"
END IF
// END IF must come after all IF/ELIF/ELSE clauses
PRINTLN "Conditional complete"NEW INT score = 85
IF score >= 90
PRINTLN "A"
ELIF score >= 80
PRINTLN "B"
END IF
// END IF closes entire IF-ELIF structure
// Cannot have more ELIF after END IFNEW INT value = 50
IF value > 75
PRINTLN "High"
ELIF value > 50
PRINTLN "Medium"
ELIF value > 25
PRINTLN "Low"
ELSE
PRINTLN "Very Low"
END IF
// Order: IF -> ELIF( s ) -> ELSE -> END IFNEW BOOL isActive = TRUE
IF isActive == TRUE
PRINTLN "System active"
END IF
PRINTLN "Status check complete"NEW INT count = 10
IF count > 5
PRINTLN "Count exceeds threshold"
END IF
PRINTLN "Count processed"NEW FLOAT temperature = 98.6
IF temperature > 98.0
PRINTLN "Elevated temperature"
END IF
PRINTLN "Temperature reading complete"NEW STR command = "start"
IF command == "start"
PRINTLN "Starting system"
END IF
PRINTLN "Command processed"NEW INT x = 5
IF x > 3
PRINTLN "Greater than 3"
// Syntax error! Missing END IF
PRINTLN "This won't compile"
// Correct:
IF x > 3
PRINTLN "Greater than 3"
END IF
PRINTLN "Program continues"NEW INT x = 5
PRINTLN "Starting"
END IF // Syntax error! END IF without matching IF
// Correct:
IF x > 3
PRINTLN "Greater than 3"
END IFNEW INT x = 5
IF x > 3
PRINTLN "Greater than 3"
END IF
END IF // Syntax error! Extra END IF
// Correct:
IF x > 3
PRINTLN "Greater than 3"
END IFNEW INT x = 5
IF x > 10
PRINTLN "High"
END IF // Syntax error! END IF too early
ELSE
PRINTLN "Low"
END IF
// Correct:
IF x > 10
PRINTLN "High"
ELSE
PRINTLN "Low"
END IFNEW INT score = 85
IF score >= 90
PRINTLN "A"
END IF // Syntax error! END IF too early
ELIF score >= 80
PRINTLN "B"
END IF
// Correct:
IF score >= 90
PRINTLN "A"
ELIF score >= 80
PRINTLN "B"
END IFNEW INT x = 10
NEW INT y = 20
IF x > 5
IF y > 15
PRINTLN "Both conditions met"
// Missing END IF for inner IF
END IF
// Syntax error! Inner IF needs END IF
// Correct:
IF x > 5
IF y > 15
PRINTLN "Both conditions met"
END IF
END IFNEW INT x = 5
IF x > 10
PRINTLN "High"
END IF // Syntax error! END IF indented too far
// Correct:
IF x > 10
PRINTLN "High"
END IFNEW INT a = 5
NEW INT b = 10
IF a > 0
IF b > 5
PRINTLN "Both positive"
END IF
END IF
// Syntax error! END IF order is wrong
// Correct:
IF a > 0
IF b > 5
PRINTLN "Both positive"
END IF
END IFNEW INT i = 1
WHILE i <= 5
IF i > 3
PRINTLN i
END WHILE
END IF
// Syntax error! END IF should be before END WHILE
// Correct:
WHILE i <= 5
IF i > 3
PRINTLN i
END IF
SET i = i + 1
END WHILENEW INT x = 5
IF x > 3
PRINTLN "Greater than 3"
END IF x > 3 // Syntax error! END IF takes no parameters
// Correct:
IF x > 3
PRINTLN "Greater than 3"
END IFNEW INT i = 1
WHILE i <= 5
IF i > 3
PRINTLN i
END WHILE // Syntax error! Should be END IF
SET i = i + 1
END IF // Syntax error! Should be END WHILE
// Correct:
WHILE i <= 5
IF i > 3
PRINTLN i
END IF
SET i = i + 1
END WHILENEW INT x = 5
IF x > 3
PRINTLN "Greater than 3"
// Missing END IF
NEW INT y = 10 // This won't execute - syntax error above
// Correct:
IF x > 3
PRINTLN "Greater than 3"
END IF
NEW INT y = 10