Please help:
I am attempting to set the text colour in rows based on the status of checkboxes in two columns. I have entered two styles called TagTBD and TagComplete, these styles define the font colour to be red and green. My script runs and sets the styles and all seems well. However if I change the status of the check box e.g. Complete from unchecked to checked which would mean a change of styles the styles do not get updated. I do attempt to remove the styles before I apply the correct style but examination of the styles in the inspector show my named styles listed under the inherited section. How should I apply or remove a named style?
Here is my script:
Tell front document of application "OmniOutliner Professional"
-- Based on the example posted by DerekM thanks Derek
-- set up some counter variables
set ObsCount to 0
set rowCounter to 0
set CompleteCounter to 0
set StyleTagTbd to named style ("TagTBD")
set StyleTagComplete to named style ("TagComplete")
repeat with oneRow in rows --onerow is the row being processed
set rowCounter to rowCounter + 1
--Remove the styles
remove StyleTagTbd from named styles of styles of oneRow
remove StyleTagComplete from named styles of styles of oneRow
if (exists child of oneRow) then
-- if the row has a child then do nothing
-- I'm interested in the lowest level of
-- the outline only
else
(*I have two columns called Obs and Complete
in my Outline. I place a tick in the obs column
if I want the row to be included.
I place a tick in the Completed Column for items that are
completed.
The columns obs and complete should be of type checked *)
set IsObs to value of cell "Obs" of oneRow
set IsComplete to value of cell "complete" of oneRow
if IsObs is "checked" then
-- increment the counter
set ObsCount to ObsCount + 1
-- Set the style to TagObs
--remove every named style from named styles of style of oneRow
--remove every style from styles of style of oneRow
--if theNamedStyle is not missing value then
add StyleTagTbd to named styles of style of oneRow
--end if
end if
if IsComplete is "checked" then
--increment the counter
set CompleteCounter to CompleteCounter + 1
--remove every named style from named styles of style of oneRow
add StyleTagComplete to named styles of style of oneRow
end if
end if
end repeat
set itemsRemaining to ObsCount - CompleteCounter
-- Script reports total number of items to process,
-- the number of completed items and the number still
-- to do.
display dialog (((ObsCount as string) & " items to process. " & CompleteCounter as string) & " items completed, " & itemsRemaining as string) & " items to complete"
end tell
I am attempting to set the text colour in rows based on the status of checkboxes in two columns. I have entered two styles called TagTBD and TagComplete, these styles define the font colour to be red and green. My script runs and sets the styles and all seems well. However if I change the status of the check box e.g. Complete from unchecked to checked which would mean a change of styles the styles do not get updated. I do attempt to remove the styles before I apply the correct style but examination of the styles in the inspector show my named styles listed under the inherited section. How should I apply or remove a named style?
Here is my script:
Tell front document of application "OmniOutliner Professional"
-- Based on the example posted by DerekM thanks Derek
-- set up some counter variables
set ObsCount to 0
set rowCounter to 0
set CompleteCounter to 0
set StyleTagTbd to named style ("TagTBD")
set StyleTagComplete to named style ("TagComplete")
repeat with oneRow in rows --onerow is the row being processed
set rowCounter to rowCounter + 1
--Remove the styles
remove StyleTagTbd from named styles of styles of oneRow
remove StyleTagComplete from named styles of styles of oneRow
if (exists child of oneRow) then
-- if the row has a child then do nothing
-- I'm interested in the lowest level of
-- the outline only
else
(*I have two columns called Obs and Complete
in my Outline. I place a tick in the obs column
if I want the row to be included.
I place a tick in the Completed Column for items that are
completed.
The columns obs and complete should be of type checked *)
set IsObs to value of cell "Obs" of oneRow
set IsComplete to value of cell "complete" of oneRow
if IsObs is "checked" then
-- increment the counter
set ObsCount to ObsCount + 1
-- Set the style to TagObs
--remove every named style from named styles of style of oneRow
--remove every style from styles of style of oneRow
--if theNamedStyle is not missing value then
add StyleTagTbd to named styles of style of oneRow
--end if
end if
if IsComplete is "checked" then
--increment the counter
set CompleteCounter to CompleteCounter + 1
--remove every named style from named styles of style of oneRow
add StyleTagComplete to named styles of style of oneRow
end if
end if
end repeat
set itemsRemaining to ObsCount - CompleteCounter
-- Script reports total number of items to process,
-- the number of completed items and the number still
-- to do.
display dialog (((ObsCount as string) & " items to process. " & CompleteCounter as string) & " items completed, " & itemsRemaining as string) & " items to complete"
end tell