Can't change style of text

I am trying to change the style of some text to italic but can’t get it to work. I am trying to use the following script to select a word and change the style to italic. The script is not very concise but I prefer to go in small steps as a learning method.

The script functions normally in Mariner Write until it gets to the line about set style. Then it stops and says: Can’t set styles of “He” to italic.

When I change the application to Claris Works, it cannot get past the first instruction.

I have Applescript version 1.5.5 on Mac OS 9.1.

I am using the script shown below. When I copies it from the Script Editor, it did not come up with the formatted version:

tell application “Mariner Write™”
activate
set char1 to “”
set char2 to “”
set text1 to “”
set text2 to “”
set text3 to “”
copy every word of document 1 as string to text1
display dialog "text1 = " & text1
set char1 to character 1 of text1
display dialog “char1 =” & char1
set char2 to character 2 of text1
display dialog “char2 =” & char2
set text2 to char1 & char2
display dialog “text2 =” & text2
–set the selection to characters 1 thru 2 of text1
–set the selection to text3
set styles of text2 to italic
display dialog “text2 =” & text2
end tell

–THIS IS A COPY OF THE DOCUMENT I AM TRYING TO WORK WITH.
–EVENTUALLY I WANT TO CHANGE THE TEXT IN THE
–THE PARENS TO ITALIC.

–Hello to all.
–(Have a nice day.)
–Goodby for now.

– Hello again.
–(Just a repeat.)
–Goodby again

The comment lines in the script were efforts to make it work. No luck.

Would appreciate comments. :?:

AppleScript, by itself, doesn’t provide the ability to change the style attributes of strings. You need to determine if Mariner Write (which I’ve never heard of) has style changing commands, ie: check it’s dictionary.

-- pseudo-code
tell application "Mariner Write™"
	set style of word 1 of document 1 to {on styles{italic}}

… or something like that.

My good friend julifos took an old script of mine and updated it for working with styled text data within vanilla AppleScript. It’s not easy to use, but you may find it interesting:

http://files.macscripter.net/scriptbuilders/Utilities/StyledTextToRecord.sit