Page 1 of 1

Embedded Applescript Trouble

PostPosted: Fri Nov 14, 2014 3:57 pm
by pruppert
I am trying to run the following embedded Applescript action. When I try to validate it in the embedded editor, I am told: expected "end" but found "property."

The script works just fine from the Applescript editor. What is going on here? How can I fix it?

Thanks.

Code: Select all
property theLocalNode : ""

on getLocalNode()
   try
      set theIP to (do shell script "ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2")
      set theLocalNode to the last word of theIP
   on error
      set theLocalNode to "Can't get Local IP"
   end try
end getLocalNode

repeat
   try
      getLocalNode()
      set textFile to path to my file
      do shell script "echo " & quoted form of getLocalNode() & "> " & quoted form of textFile
      exit repeat
      
   on error
      exit repeat
   end try
end repeat

Re: Embedded Applescript Trouble

PostPosted: Fri Nov 14, 2014 4:58 pm
by Mr_Noodle
Read the help on AppleScript. You can't use handlers in an embedded script because it is already in a handler.