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