Differentiate Event based on how many folders are selected (like if-else)

I've created a middle double-click event (like this) which opens the selected folder in a new tab.

How can I now modify Go NEWTAB=findexisting so that it differentiates between how many folders are selected? I only want to open a new tab if one folder is selected. When multiple folders are selected I'd like to do something else.

Like this (number of selected folders = {sd}?):
If({sd}=1) {
Go NEWTAB=findexisting
} else if({sd}>1) {
do something else
}

Using JScript or VBScript is the way to do that. See Scripting for an introduction.

Making it work in a toolbar button first will be easiest, as you can test-run it and the button editor has some features that the file type event editor lacks. (In particular, it'll give you a default script that shows you how to do a lot of things as soon as you switch a new button into script mode.)

Once you have a working script, you can cut & paste it into a file type event. The only thing you may need to add is a line with @script jscript (or @script vbscript) at the top to tell it which language was used. That isn't needed in the button editor as it has a drop-down just above where you type the script which serves the same purpose.

Take a look at the button editor's defualt/example script and the Scripting Reference at the back of the manual and most things you need should be there. Shout here on the forum if you need help or directions.