Nisus writer macro

Could someone tell my why this script to CAPITALIZE does not work properly in nisus writer

-- change case subroutine from applescript resources at
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"
		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
			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?

I remember this app Nisus Writer. What’s good about it?


Dont like using MS Word.
Like OpenOffice interface Better.
To run Openoffice, I have to use parallels desktop.
Never tried OO with X windows.
Neither of these are very scriptable.

Nisus writer supports applescript macros and perl macros + it Opens .doc files
It opens word files but does not somehow show the inserted pictures in the files.
It does not have a navigator feature like OO or word document.
Everything else is good about it.

Here is the same script that I was trying applescript to do for me done by tweaking another nisus writer perl script.
Glad I get the same result.

binmode(STDIN, “:utf8”);
binmode(STDOUT, “:utf8”);

my $text;
while (my $line = ) {$text .= $line;}
my $line = uc($text);
print “$line”;


I don’t have Nisus Writer, but you probably need a short delay after the ‘keystroke “x”’ command to allow the keystroke’s effect to take place. The command’s independent of GUI Scripting, so you don’t need to address it to the process.

tell application "Nisus Writer Express" to activate
tell application "System Events"
	keystroke "x" using {command down} -- I'd personally prefer "c".
	delay 0.3 -- Increase if necessary.
	set theClipboard to the clipboard
	set the clipboard to my change_case(theClipboard, 1)
	keystroke "v" using {command down}
end tell

Thanks Nigel