View Single Post
This should toggle the numbering of selected rows.

(In the absence of existing numbering, it defaults to legal with a trailing "." - this can be adjusted by editing the first four properties)

Code:
-- DEFAULT NUMBERING SETTINGS (ADJUST AS REQUIRED)
property pvarLowerCase : true
property pvarPrefix : ""
property pvarSuffix : "."
property pvarType : "Legal" -- Legal | Letters | Numeric | Roman

property plstNumbered : {pvarLowerCase, pvarPrefix, pvarSuffix, pvarType}

on run
	tell application id "OOut"
		-- IS THERE A FRONT DOCUMENT ?
		set lstDocs to documents
		if (count of lstDocs) < 1 then return
		set oDoc to first item of lstDocs
		
		-- ARE ANY ROWS SELECTED ?
		set refRows to a reference to selected rows of oDoc
		if (count of refRows) < 1 then return
		
		-- IS THE FIRST SELECTED ROW NUMBERED ?
		set blnNumbered to false
		set {lstAttribs, lstValue, lstDefault} to {name, value, default value} of ¬
			(attributes of (style of (first item of refRows)) where name begins with "heading")
		set lngAttribs to length of lstValue
		repeat with i from lngAttribs to 1 by -1
			if item i of lstValue ≠ item i of lstDefault then
				set blnNumbered to true
				exit repeat
			end if
		end repeat
		
		-- TOGGLE VALUES ACCORDINGLY
		if blnNumbered then
			-- STORE CURRENT PATTERN OF NUMBERING IN A PERSISTENT VARIABLE
			set plstNumbered to lstValue
			set lstSettings to lstDefault
		else
			set lstSettings to plstNumbered
		end if
		
		-- APPLY THE TOGGLED SETTINGS TO ALL SELECTED ROWS
		repeat with i from 1 to lngAttribs
			set value of attribute (item i of lstAttribs) of style of refRows to item i of lstSettings
		end repeat
	end tell
end run
--

Last edited by RobTrew; 2011-09-20 at 06:47 AM.. Reason: Light edit to code - slightly simplified