Indesign CS2: getting total width and height of rows and columns

I’m trying to get the total width and height of selected cells in a table and display those in a dialog box.

I’ve been able to copy and paste some portion of scripts I already had or did at some point, but I’m pretty rusty these days and would like some help.

Here’s what I got so far:


tell application "Adobe InDesign CS2"
	set myDocument to active document
	tell myDocument
		--set units to points
		if horizontal measurement units of view preferences of myDocument is not points or ¬
			vertical measurement units of view preferences of myDocument is not points then
			set myOldViewPreferences to properties of view preferences of myDocument
			set horizontal measurement units of view preferences of myDocument to points
			set vertical measurement units of view preferences of myDocument to points
			set myResetUnits to true
		else
			set myResetUnits to false
		end if
	end tell
	set myWidth to width of cells of selection as list
	
	my myTotal(myWidth)
	
	--Resets the units  
	if myResetUnits is true then
		tell view preferences of myDocument to set properties to myOldViewPreferences
	end if
	
end tell

on myTotal(numbers_list)
	try
		set numbers_total to 0
		repeat with i from 1 to count numbers_list
			set the_number to item i of numbers_list
			set numbers_total to numbers_total + the_number
		end repeat
		set theWidth to numbers_total
		
	end try
	display dialog "Width: " & numbers_total & " pt"
end myTotal

I’m using a handler taken from a Hanaan Rosenthal’s book, but I can’t figure out how to display the dialog outside of the handler. Since I only did the width in this script, I need to add the height, so I was thinking that I should do both with the same handler, but I can’t figure it out.

On another note, I’ve forgot how to convert my units into other kinds of units. In this case its points but I’d like to convert them to Picas. Even better, if I could have the dialog display the same value in points, picas, inch, that would be very cool.

Any help appriciated!
TIA
Jeff