Could someone tell my why this script to CAPITALIZE does not work properly in nisus writer
-- change case subroutine from applescript resources at apple.com
on change_case(this_text, this_case)
if this_case is 0 then
set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set the source_string to "abcdefghijklmnopqrstuvwxyz"
else
set the comparison_string to "abcdefghijklmnopqrstuvwxyz"
set the source_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end if
set the new_text to ""
repeat with this_char in this_text
set x to the offset of this_char in the comparison_string
if x is not 0 then
set the new_text to ¬
(the new_text & character x of the source_string) as string
else
set the new_text to (the new_text & this_char) as string
end if
end repeat
return the new_text
end change_case
tell application "System Events"
tell process "Nisus Writer Express"
keystroke "x" using {command down}
set theClipboard to the clipboard
set the clipboard to change_case(theClipboard, 1) of me
keystroke "v" using {command down}
end tell
end tell
With the clip board empty and on making a selection in the document, Upon running the script, Iget the correct result.
But if I do a copy to clipboard from another application and later make a selection in the Nisus writer and run the script, I get the capitalized text that was copied earlier.
Is there some way I can empty the clipboard before copying text from Nisus writer to be processed by this applescript?
Or is there a better way to implement this functionality via applescript?