123Macmini.com
FAQFAQ   SearchSearch   MemberlistMemberlist   GalleryPhoto Gallery   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple applescript

 
Post new topic   Reply to topic    123Macmini.com - Forums Forum Index -> Off Topic
View previous topic :: View next topic  
Author Message
maurice
Member
Member


Joined: 11 Sep 2007
Posts: 112

PostPosted: Thu Oct 24, 2013 5:41 am    Post subject: Simple applescript Reply with quote

Hi,

I have tried the pretty basic script below in Script Editor, but it will not compile. Can someone please tell me why?

tell application "Caffeine"

if active then

turn off

else

turn on

end if

end tell
Back to top
View user's profile Send private message
Cypher
Veteran Member
Veteran Member


Joined: 24 Jan 2007
Posts: 3097
Location: North West - UK

PostPosted: Thu Oct 24, 2013 2:00 pm    Post subject: Reply with quote

copying and pasting yours in to the Applescript editor gave



notice the lines between the code lines

Code:

tell application "Caffeine"


if active then


turn off


else


turn on


end if


end tell





If you remove the white space between code lines it will compile

Code:

tell application "Caffeine"
   if active then
      turn off
   else
      turn on
   end if
end tell




I tested it on mine and Caffeine does enable and disable as required.
_________________
Phil

Mac Mini 2.53GHz - iMac 2.0Ghz - Macbook Pro 2.4GHz - iPad 1 32GB 3G
6TB Netgear Ready NAS NV+ - 6TB Drobo S
Back to top
View user's profile Send private message
maurice
Member
Member


Joined: 11 Sep 2007
Posts: 112

PostPosted: Thu Oct 24, 2013 6:00 pm    Post subject: Reply with quote

I didn't expect the spaces between the lines to be the problem. Thank you very much for your prompt reply.
maurice
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    123Macmini.com - Forums Forum Index -> Off Topic All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



      

Shop:  Apple Store  |  Refurbished Macs  |  Refurbished iPads  |  MacConnection  |  Mac Mini Vault  |  Other World Computing

MK 1 Studio Mac mini Racks  |  Crucial Mac Memory  |  Top Free Mac Apps  |  Top Paid Mac Apps



123Macmini.com is an independent publication and has not been authorized, sponsored, or approved by Apple Computer, Inc.
All logos and trademarks in this site are property of their respective owners.
Copyright © 2011 123Macmini.com. All Rights Reserved.