simple applescripting

Have a problem? A question? This is the place for answers from other Express users.
Post Reply
pdumais
Posts: 3
Joined: 2004-10-02 12:38:56

simple applescripting

Post by pdumais »

Hi folks, need a little help.

can I insert text into the frontmost document through Applescript ? Say the contents of a variable ? Having problems figuring out basic things.

thanks
cchapin
Posts: 424
Joined: 2004-02-25 18:28:40
Location: Nagoya, Japan

Post by cchapin »

That should be possible. I'm very new to AppleScript, but I know you can use "set" to change a specified word or paragraph. For instance, I wanted to have a macro to create a fresh letter and insert the date. I created the letter template, writing "<DATE>" in the last paragraph. Here's AppleScript to create a new letter.

<pre>tell application "Nisus Writer Express"
activate
set letterTemplate to "INSERT_YOUR_PATH_HERE:Letter.dot"
open letterTemplate
if paragraph -1 of text of document 1 is "<DATE>" then
set monthNow to month of (current date) as string
set dayNow to day of (current date)
set yearNow to year of (current date)
set dateNow to monthNow & " " & dayNow & ", " & yearNow
set paragraph -1 of text of document 1 to dateNow
end if
end tell</pre>

This is my very first -- and so far only -- AppleScript, so I imagine it's far from perfect, but it seems to work.

--Craig
charles
Posts: 481
Joined: 2002-11-26 11:40:35
Location: San Diego, CA
Contact:

Post by charles »

Great work, Craig!

-C
Charles Jolley
Nisus Software, Inc.
Post Reply