• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to do a goto with Applescript?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to do a goto with Applescript?


  • Subject: Re: How to do a goto with Applescript?
  • From: Alex Zavatone <email@hidden>
  • Date: Mon, 10 Jan 2011 13:12:31 -0600

if x contains "Finder" then

else if x contains "Mail" then 

else if x contains ...

NEVER DO THIS.

At the very least, go to a function that handles Mail, such as HandleMailApp, or what to do in the Finder such as HandleFinderApp

Declare a variable for your monitor size and use a lookup table of monitor sizes to determine what to do based on the result.

You've got a 500 line main handler.  

Start declaring some properties and start referencing them.  

Never call a variable x.  If x is your  application's name, then call it myApp.  

We now have the option of using descriptive variable names.  Calling variables, i, j, or x is meaningless.  Call the variable what it represents.  I use the short, but effective prefix of "my" to indicate that it is a local.

For the love of puppies, please preface your globals with a g.  This tells you instantly that it is a global.  You don't have to think about it, you just know.

Like so:
gMonitorSize
pMonitorSize
myMonitorSize


You only will become a better programmer when you learn to break these habits.


On Jan 10, 2011, at 12:01 PM, Robert Poland wrote:

<setBounds.zip>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to do a goto with Applescript?
      • From: Doug McNutt <email@hidden>
References: 
 >How to do a goto with Applescript? (From: Robert Poland <email@hidden>)
 >Re: How to do a goto with Applescript? (From: AndrĂ© Renault <email@hidden>)
 >Re: How to do a goto with Applescript? (From: Robert Poland <email@hidden>)
 >Re: How to do a goto with Applescript? (From: Michelle Steiner <email@hidden>)
 >Re: How to do a goto with Applescript? (From: "Mark J. Reed" <email@hidden>)
 >Re: How to do a goto with Applescript? (From: Robert Poland <email@hidden>)
 >Re: How to do a goto with Applescript? (From: "Mark J. Reed" <email@hidden>)
 >Re: How to do a goto with Applescript? (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: How to do a goto with Applescript?
  • Next by Date: Re: How to do a goto with Applescript?
  • Previous by thread: Re: How to do a goto with Applescript?
  • Next by thread: Re: How to do a goto with Applescript?
  • Index(es):
    • Date
    • Thread