Re: Non Compulsory Parameters & a Null Constant ?
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.