nisus.com
https://www.nisus.com/forum/

Applescript advice for variables and other issues
https://www.nisus.com/forum/viewtopic.php?f=17&t=4337
Page 1 of 1

Author:  loulesko [ 2011-06-05 13:35:35 ]
Post subject:  Applescript advice for variables and other issues

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:
$code = "
tell application \"MarsEdit\"
   activate
   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
Lou

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/