I think you were missing an end if. Each if then statement that has multiple lines mush have one.
Also please refrain from putting comments on lines with if then statements. it can cause some problems with the parcer.
' if relay off then check if time to turn on for time 2
if RelayON = -1 then
if T2Hon = hh then
if T2Mon = mm then
RelayON = T2D
goto [RlyOn]
end if
end if
end if
http://esp8266basic.com
A BASIC interpreter for your ESP
Working now on Autodrop3d. A 3d printer with automatic part ejection system. https://autodrop3d.com