i read this quickly but think this is what u want , remove the commented endif

also try use code encapsulated when adding code to post ,

cheers


Code:
IF fsmState = idleSt THEN
    IF kpLastValue != kpValue THEN
       hserout[CR, LF, "***DEBUG - idleSt, br: mainMenuSt ", CR, LF]
       kpLastValue = kpValue
       fsmNextState = mainMenuSt
      ' Remove this   ENDIF i think 
    ELSE
       hserout[CR, LF, "***DEBUG - drawIdle check ", CR, LF]
 
        IF sec != lineSecondsLast THEN
             gosub drawIdle
             lineSecondsLast = sec
             lineMinutesLast = minute
             lineHoursLast = hour
             lineDayLast = day
             lineMonthLast = month
             lineYearLast = year
             lineCenturyLast = century
        ENDIF

   ENDIF

ENDIF