Page 1 of 1

Applescript advice for variables and other issues

Posted: 2011-06-05 13:35:35
by loulesko
After much consternation and experimentation I was able to get an Applescript to work properly. The Applescript sends my NWP text to MarsEdit blogging software for publishing. Here's the code:

Code: Select all

$code = " 
tell application \"MarsEdit\"
	set theSubj to \"$subject\"
	set theText to \"$text\"
	set theBlog to \"$blog\"
	make new document
	set the current blog of document 1 to blog theBlog
	tell document 1
		set body to theText
		set title to theSubj
	end tell
end tell"

$error = ""
$result = Run AppleScript $code, $error
The things to note are in order for your Nisus macro variables to expand (is that the correct word?) the entire block of Applescript code needs to be enclosed in double quotes with your variables placed between escaped double quotes. In the macro guide single quotes are used in the example - not that that is wrong, it just won't work for setting Applescript variables from Nisus macro variables. Also, I highly recommend that before setting your $text variable, select your entire document and run the Edit > Convert > Plain Quotes to Smart Quotes command on the text. Applescript doesn't like plain quotes and your script will error, but it doesn't mind smart quotes.

All the best