This endif Does Not Have a Matching If Preceding It
From Xojo Documentation
Error message
An #If statement was omitted from an #If...#Endif structure.
Examples
The If statement in this example should be #If...#Endif.
See Also
#If...#Endif statement.