• 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: Non Compulsory Parameters & a Null Constant ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non Compulsory Parameters & a Null Constant ?


  • Subject: Re: Non Compulsory Parameters & a Null Constant ?
  • From: Paul Skinner <email@hidden>
  • Date: Wed, 12 Feb 2003 11:46:57 -0500

On Tuesday, February 11, 2003, at 11:10 PM, Adam Hinshaw wrote:

hi all.

couple of basic queries.

is there a way to specify parameters in a handler that are not compulsory in a call to that handler.

eg;
on getFoo(bar)
(*do stuff*)
end

set myVar to getFoo(12) -- current way

but what if i did not want to pass a param as my handler will use a default value instead or respond in a different manner,

snip

thanks
adam.

I prefer to pass parameters to handlers as a record; you can then pass a few... {x:"x's value"}, a lot... {x:"x's value",y:"y's value",z:"z's value"} or no parameters... {}. Records cause no positional parameter issues and are very flexible.

DoSomethingCool(parameters)

on DoSomethingCool(parameters)
try
set x to x of parameters--If no value for x is passed then make one up.
on error
set x to "Default Value for x"
end
return x
end

--
Paul Skinner

"The Church says the Earth is flat. But I know the Earth is round, for I have seen the shadow on the moon, and I have more faith in a shadow than in the Church." - Magellan
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: 
 >Non Compulsory Parameters & a Null Constant ? (From: Adam Hinshaw <email@hidden>)

  • Prev by Date: applescript CGI under 10.2.3 (server)
  • Next by Date: Re: search and replace in tex-edit
  • Previous by thread: Re: Non Compulsory Parameters & a Null Constant ?
  • Next by thread: Re: applescript-users digest, Vol 3 #1332 - 17 msgs
  • Index(es):
    • Date
    • Thread