Tab Enabling/Disabling commands
Bob Sneidar
bobs at twft.com
Mon Apr 30 17:11:52 EDT 2012
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
More information about the use-livecode
mailing list