• 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: Skeeve <email@hidden>
  • Date: Tue, 11 Jan 2011 22:53:15 +0100

A similar way. This time the is_PROGRAMNAME handlers "decide" whether or not they need to process.

I think it's self-explaining, isn't it?

Just take care that your handlers return false if they didn't process and true if they did.

---------------------
on run
    repeat
        -- get a programname from somewhere
        set chosen to choose from list {"Finder", "Acrobat", "Mail"}
        -- Cancel was clicked
        if chosen is false then
            return
        end if
        set chosen to first item of chosen
        -- check all known programs
        is_Finder(chosen) or ¬
            is_Acrobat(chosen) or ¬
            is_Mail(chosen)
    end repeat
end run

-- these handlers only display a dialog. Feel free to add what you want
on is_Finder(pname)
    -- check correct program
    if pname does not contain "Finder" then return false
    -- process here
    display dialog "Finder"
    -- done
    return true
end is_Finder

on is_Acrobat(pname)
    -- check correct program
    if pname does not contain "Acrobat" then return false
    -- process here
    display dialog "Acrobat"
    -- done
    return true
end is_Acrobat

on is_Mail(pname)
    -- check correct program
    if pname does not contain "Mail" then return false
    -- process here
    display dialog "Mail"
    -- done
    return true
end is_Mail
-------------------------


I have no idea how long the "check all known programs" line may be. Could well be that there is a too small limit to be usable. In that case, I'd go for


repeat 1 time
    if is_Finder(chosen) then exit repeat
    if is_Acrobat(chosen) then exit repeat
    if is_Mail(chosen) then exit repeat
end repeat
_______________________________________________
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
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>)
 >Re: How to do a goto with Applescript? (From: Skeeve <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