Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 753919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:57:09+00:00 2026-05-14T14:57:09+00:00

In Applescript, if you declare a handler using with labeled parameters, local variables get

  • 0

In Applescript, if you declare a handler using “with” labeled parameters, local variables get the values of the arguments and the parameters themselves are undefined. For example:

on bam of thing with frst and scnd
    local eat_frst
    return {thing: thing, frst:frst, scnd:scnd} -- this line throws an error
end bam
bam of "bug-AWWK!" with frst without scnd 

results in an error message that “scnd” isn’t defined in the second line of bam. thing and frst are both defined, getting the arguments passed in the call to bam. Why is this happening? Why is scnd undefined?

Note: I know that declaring variables as “local” within a handler is unnecessary. It’s done in the examples for illustrative purposes.

Here are some more examples that don’t throw errors, illustrating what variable gets what value. To distinguish between the first and second given parameters, each handler is invoked with the first given parameter and without the second given parameter. Note that using the given userLabel:userParamName syntax has no problems with value capturing.

on foo of thing given frst:frst_with, scnd:scnd_with
    local eat_nothing
    return {frst:frst_with, scnd:scnd_with}
end foo

on bar of thing with frst and scnd
    local eat_frst
    return {frst:eat_frst, scnd:scnd}
end bar

on baz of thing with frst and scnd
    eat_frst
    local eat_scnd, eat_others
    return {frst:eat_frst, scnd:eat_scnd}
end baz

{foo:(foo of "foo" with frst without scnd), ¬
 bar:(bar of "bar" with frst without scnd), ¬
 baz:(baz of "baz" with frst without scnd)}

Result:

{ foo:{frst:true, scnd:false}, 
  bar:{frst:true, scnd:false}, 
  baz:{frst:true, scnd:false}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:57:10+00:00Added an answer on May 14, 2026 at 2:57 pm

    After playing with it for a bit, the answer appears to be that using with labeled parameters doesn’t introduce variables. Instead, the values are assigned to local variables in the order they’re encountered in the handler body.

    Illustrative examples:

    on baa of thing with frst and scnd
        scnd
        frst
        return {frst:scnd, scnd:frst}
    end baa
    
    on bas of thing with frst and scnd
        -- note that eat_frst gets the value of the frst parameter,
        -- then gets set to "set"
        set eat_frst to "set"
        eat_scnd
        return {frst:eat_frst, scnd:eat_scnd}
    end bas
    
    on qux of thing with frst and scnd
        if scnd then
        end if
        local eat_scnd, eat_others
        return {frst:scnd, scnd:eat_scnd}
    end qux
    
    on quux of thing with frst and scnd
        if frst then
        end if
        if eat_scnd then
        end if
        return {frst:frst, scnd:eat_scnd}
    end quux
    
    {  baa: (baa of "baa" with frst without scnd), ¬
       bas: (bas of "bas" with frst without scnd), ¬
       qux: (qux of "qux" with frst without scnd), ¬
      quux: (qux of "qux" with frst without scnd) }
    

    Result:

    {  baa:{frst:true, scnd:false},
       bas:{frst:"set", scnd:false},
       qux:{frst:true, scnd:false}, 
      quux:{frst:true, scnd:false}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 484k
  • Answers 484k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check this blog post: ORA-27123: unable to attach to shared… May 16, 2026 at 7:32 am
  • Editorial Team
    Editorial Team added an answer C is simple to learn, difficult to master. as a… May 16, 2026 at 7:32 am
  • Editorial Team
    Editorial Team added an answer I know neither Java nor Grails, so there may be… May 16, 2026 at 7:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.