• 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: Michelle Steiner <email@hidden>
  • Date: Tue, 11 Feb 2003 21:31:48 -0700

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

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,

eg;
set myVar to getFoo() -- gets a runtime error "...doesn't match the
parameters"

So is there away around these errors.

I can think of two ways to do it; one is not to put anything inside the parens in the header of the handler e.g.;

on getFoo ()

If, though, you need to sometimes use the value and sometimes not, pass Missing value as the parameter, and test for that value within the handler, maybe like this:

foo(missing value)

on foo(bar)
if bar is missing value then
--default routine goes here
else
--use bar here
end if
end foo

There are other ways to handle it, but all that I can think of depend on if-then statements.

--Michelle

--
"There's some good in the world, Mr. Frodo, and it's worth fighting for."
_______________________________________________
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: Non Compulsory Parameters & a Null Constant ?
  • Next by Date: Re: Remote Access and Network Setup Scripting problems under OS 9.1 (and 9.2.1)
  • Previous by thread: Non Compulsory Parameters & a Null Constant ?
  • Next by thread: Re: Non Compulsory Parameters & a Null Constant ?
  • Index(es):
    • Date
    • Thread