Slight update to accommodate wholeMatches. It's conceivable someone might pass one word of a two word tab name, and I would have gotten the wrong tab! eg. Base, First Base, Second Base, etc.
ON disableTab theTabPanel, theTab IF theTabPanel is empty THEN exit disableTab IF not there is a button theTabPanel THEN exit disableTab put the text of button theTabPanel into theTabOptions IF theTab is "All" THEN REPEAT WITH i = 1 to the number of lines of theTabOptions IF char 1 of line i of theTabOptions is not "(" THEN put "(" before line i of theTabOptions END IF END REPEAT ELSE SWITCH CASE theTab is a number IF theTab > the number of lines of theTabOptions OR theTab = 0 THEN exit disableTab IF char 1 of line theTab of theTabOptions is not "(" THEN put "(" before line theTab of theTabOptions END IF break CASE theTab is not a number set wholematches to true put lineoffset(theTab, theTabOptions) into theTabLine IF theTabLine = 0 THEN exit disableTab IF char 1 of line theTabLine of theTabOptions is not "(" THEN put "(" before line theTabLine of theTabOptions END IF break END SWITCH END IF set the text of button theTabPanel to theTabOptions END disableTab ON enableTab theTabPanel, theTab put the text of button theTabPanel into theTabOptions IF theTab is "All" THEN REPEAT WITH i = 1 to the number of lines of theTabOptions IF char 1 of line i of theTabOptions is "(" THEN put empty into char 1 of line i of theTabOptions END IF END REPEAT ELSE SWITCH CASE theTab is a number IF theTab > the number of lines of theTabOptions OR theTab = 0 THEN exit enableTab IF char 1 of line theTab of theTabOptions is "(" THEN put empty into char 1 of line theTab of theTabOptions END IF break CASE theTab is not a number set wholematches to true put lineoffset(theTab, theTabOptions) into theTabLine IF theTabLine = 0 THEN exit enableTab IF char 1 of line theTabLine of theTabOptions is "(" THEN put empty into char 1 of line theTabLine of theTabOptions END IF break END SWITCH END IF set the text of button theTabPanel to theTabOptions END enableTab _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode