Error on var declaration

I have finally working Designer again thanks to sihui’s remark in this forum.
Now i try to get a simple timer to work from a given example. I would like to turn on ventilation when the light goes on, but turn off ventilation 5 minutes after the light goed out.
I understand in OH2 we do not need to import anything? (Or just the timer module?). But I have an error even on the first line with var. Designer is saying: “missing ‘EOF’ at var”.
What do I do wrong?

var Timer timer = null
rule "Ven_bad_uit"
when
Item Lamp_BK received command
then
if(receivedCommand==ON) {
Ven_BK.sendCommand(ON)
} else {
if(timer==null) {
timer = createTimer(now.plusMinutes(5)) [|
Ven_BK.sendCommand(OFF) //MyItem.sendCommand(new_state)
timer = null
]
}
}
end

For help with timers in general, search the forum for “Design Pattern Timer” rlkoshak wrote a lot of extremely helpful advice.

But my point is rather with regard to the Designer. The Designer is beyond its lifetime and not any longer supported. It does throw quite a number of errors that are not real errors but rather a sign of how outdated it has become. Visual Studio Code (note: VSCode is freely available) is the officially supported editor now: https://docs.openhab.org/configuration/editors.html

VSCode does not label your first line as error.

Ok, you are right, using Visual Studio Code there is no error. But still it is not working like it should. I will read up on your suggested key words.
Thanks!

Ok, the reading has to wait a little, there is till something odd going on with this var declaration. I started out simpel:

rule "Ven_bad_aan"
when
	Item Lamp_BK changed from OFF to ON
then
	Ven_BK.sendCommand(ON)
end

//var Timer timer = null
rule "Ven_bad_uit"
when
	Item Lamp_BK changed from ON to OFF
then
//	if(timer==null) {
//   			timer = createTimer(now.plusSeconds(10)) [|
    				Ven_BK.sendCommand(OFF) //sendCommand(Ven_BK,"OFF") MyItem.sendCommand(new_state)
//    				timer = null
//	}
end

With the // in place, this is working correctly: The ventilation follows the lighting closely. But as soon as I take away the // in front of the var-declaration, the ven stays off and when I manually turn it on, it will not go off with the lights either.
This has nothing to do with the Timer yet, since anything like this: var i = 10, will do the same!

I have the timer working with the expire-binding, which I found through your suggested reading! Thanks again for that.
But I still wonder for future rules with var-declarations: why is my rule-file screwed up when adding a var declaration?

var definitions outside a rule have to reside at the very beginning of the rules file:

// start of rules file
// 1st: imports
import ...
// 2nd: val and var
var Timer timer = null
...
// 3rd: rules
rule "1st rule"
when
then
end

...

Aiaiai, I do feel stupid. I just tested and it works.
I must have read that of course. But I sometimes don’t have time to spend on this for months. So I forget things if I didn’t use it yet. My so called steep learning curve show a bit of a saw tooth.
Thank you very much!