Help with timer problems

I’ve been attempting to use Rich’s excellent timer example to blink a light every 1-3 seconds. Problem is I’m running into an error. mismatched “)” error?

  1. I’ve noticed that using VSC I sometimes need to retype in lines because “rules” don’t see the code the the way I see them? I think there is hidden text creeping in from cut and paste but not sure? I only mention this because I just thought that could be my problem and I need to go try re-entering everything.
  2. If it is not then I don’t see where I’m missing “)” as indicated with this simple code.

    rule “Weather Room lights”

when

 Time cron "0/30 * * ? * *"  

then

        // Create a timer to blink the light for 30 seconds 

 timer = createTimer(now, [ | 

    CliffOfc_Wall_Light.sendCommand(if(CliffOfc_Wall_Light.state == 100) 0 else 100)

    if(now.isBefore(timeStarted.plusSeconds(30) timer.reschedule(now.plusSeconds(2)) 

    else timer = null

])

end

It can’t get much simpler than this yet I get this error?

2020-03-21 19:50:26.455 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘myrules.rules’ has errors, therefore ignoring it: [15,53]: mismatched input ‘timer’ expecting ‘)’

There is nothing more to the rule or in the .rules file than this? Anyone got an idea?

This may be a copy paste error in your message, but -

rule “Weather Room lights”    // this is a syntax error

rule "Weather Room lights"    // this is ok

Spot the difference - the type of quote marks are important, and do get mangled in copy/paste.
It’s why use of code fences is important in this forum.

This line contains five ( and three ) , so you know you haven’t paired them correctly.

You miss a declaration: val timer = createTimer.....

Thanks, code fences was/is acting up. You see the end below the fence. In my posting it is inside the fence. Why it and the top line decided to stay outside the fences is a mystery to me.
Thanks for the tip, I had tried and counted all the “()” many times and still got an error. As I said I went back in and re-typed the lines and it was fine. I think the text from the community contained hidden formatting chars and caused an issue.
Bottom Line it is now working as planned
Thanks for the help!
Cliff