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. :?: