# Creating a "no group" option in a ui menu (kontakt script)



## mikerodi (Oct 10, 2013)

Hi there, 
I have a problem... I've created a set of menus which display all groups in an instrument, but I also need an item (in the menus) where no group is selected and the only way I can achieve this is by creating an empty group and naming it eg. NO GROUP. 

Is there a way I can avoid having to create an empty group i.e. by adding another item in the menu? But then, what value do I give it? 

Can't be zero as that would imply the first group... 

Help would be greatly appreciated... 

Michael.


----------



## Big Bob (Oct 10, 2013)

Hi Michael,

You could use -1 (or any index outside the range from 0 to 4095). Then in your callback handler for the menu, test for the -1 and handle it as an exception.

Rejoice,

Bob


----------



## polypx (Oct 10, 2013)

Just in case Bob's suggestion isn't clear, this is a quick way to set up a menu like that:


```
declare $count
declare ui_menu $Group
add_menu_item ($Group, "No Group", -1)
while ($count < $NUM_GROUPS)
	add_menu_item ($Group, group_name($count), $count)
	inc($count)
end while
```

cheers, Dan


----------



## mikerodi (Oct 15, 2013)

Thanx Bob and polypx... You have been very helpful.
Had thought about it, but thought that -1 would have referred to all groups, which I must say has confused me a bit, but I'll get around it...


----------



## Big Bob (Oct 15, 2013)

Well the assumption is that you would test for -1 and then take whatever special action you needed to take. I didn't mean to imply that you should use -1 as an actual group number.

Also, keep in mind that you can use any integer value outside of the normal 0..4095 range, so if you want to use a positive number that doesn't represent any actual group, just use 4096 or 10000 or whatever :lol: 

Rejoice,

Bob


----------



## mikerodi (Oct 15, 2013)

Hadn't really understood what you meant by test,
But I've got it now... Thanks a lot Bob.


----------

