Previous  |  Main  |  Next
AppleScript Logo

Count Characters of Selected Frame / Text

Script for: QuarkXPress
Copyright: Matthias Steffens, use at your own risk!
Description: Counts all selected characters or the
characters contained in a selected text box.
Necessary: None
Download: Count_Chars(XPress).hqx
Count_Chars(XPress)_dt.hqx  (german version)
The Script:
tell application "QuarkXPress 3.3"
	if exists (document 1) then
		tell document 1
			if exists selection then
				if (box type of current box) = text box then
					try
						set x to every text of selection
						if x = "" then
							my GetHelp()
						else
							set ct to count characters of x
							display dialog "The selection contains " & ct & " characters." buttons {"OK"} default button 1 with icon note
						end if
					on error errText number errNum
						display dialog errText & return & return & ¬
							"(Error No: " & errNum & ")" buttons {"OK"} default button 1 with icon note
					end try
				else
					my GetHelp()
				end if
			else
				my GetHelp()
			end if
		end tell
	else
		display dialog "A document must be open in order to use this script." buttons {"Help", "OK"} default button 2 with icon note
		if button returned of result is "Help" then my GetHelp()
	end if
end tell


on GetHelp()
	display dialog "This script counts all selected characters or the characters" & return & "contained in a selected textbox." & ¬
		return & return & "So you have to select some text" & return & ¬
		"or a single textbox in order to" & return & "use this script." buttons "OK" default button 1 with icon note
end GetHelp

 


Contact: Matthias Steffens  |  Previous  |  Main  |  Next  |  Last Updated: 11-Mar-00