Re: Non Compulsory Parameters & a Null Constant ?
Re: Non Compulsory Parameters & a Null Constant ?
- Subject: Re: Non Compulsory Parameters & a Null Constant ?
- From: has <email@hidden>
- Date: Wed, 12 Feb 2003 18:05:28 +0000
Adam Hinshaw wrote:
is there a way to specify parameters in a handler that are not compulsory in
a call to that handler.
Handler parameters are non-optional (annoying, but that's how it is).
You can work around this when you have to:
on doSomething(paramRec)
set {foo:foo, bar:bar} to paramRec & {foo:0, bar:false}
log foo
log bar
end
doSomething({})
doSomething({foo:4})
doSomething({foo:19, bar:true})
It's kinda ugly, but may be the lesser evil when writing handlers
that must have this level of flexibility and self-sufficiency (e.g.
reusable libraries). Rest of the time, it's simpler just to be
explicit:
on doSomething(foo, bar)
...
end
If it'll make your code easier to read/maintain, you can always
define your default values up front as 'constants':
-- constants/default values
property dcFoo : 0
property dcBar : false
...
doSomething(dcFoo, dcBar)
doSomething(dcFoo, true)
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.