Obtaining the Tab Index

I have a script which I want to perform different actions, depending in which tab in a Tab Set is active, but I am having great difficulty in working out how I can get the index number of the currently selected tab.

Could anyone help me out, please?

You can usually pass the tab to commands without getting its index, but if you really need the index then one way is to loop through the tabs, counting them and stopping once you find the current one.

Many Thanks Leo... sorted.