Re: Deafult or optional arguments to handlers
Re: Deafult or optional arguments to handlers
- Subject: Re: Deafult or optional arguments to handlers
- From: email@hidden (Michael Sullivan)
- Date: Tue, 23 Apr 2002 12:43:40 -0400
- Organization: Society for the Incurably Pompous
Paul Skinner writes:
>
I do this like so...
>
>
handlerName(parameters)
>
--pass in positional parameters labled parameters or a single
>
parameter and handle parsing the parameters in the handler. Calls with
>
no parameters must have some argument ie.("",{},1,pi}.
>
>
on handlerName(parameters)
>
if class of parameters is record then--appropriate if statement here
>
set requiredParameter to parameters
>
--or
>
set requiredParameter to item 1 of the parameters
>
--or
>
set requiredParameter to requiredParameter of parameters
>
--and/or
>
--appropriate optional parameter IF statement here
>
set optionalParameter to someItemOfTheParametersAsAppropriate
>
--or
>
set optionalParameter to "default value"
>
--end appropriate optional parameter IF statement here
>
end if
>
end handlerName
>
>
I use a handler wrapper that makes all my handlers have 1 parameter
>
like this and also provides them with an identity and documentation.
>
This lets me modify the handler later and retain backwards compatability
>
with older scripts. Passing any handler the parameter 'missing value'
>
will return a record of useful information about the handler and it's
>
usage. Linewraps are obvious
I like this. This is probably what I'll use wherever speed is not
potentially absolutely critical.
I especially like your idea of using missing value to return the API
documentation!
I'd still like the language better if Timothy Bates' suggestions were
implemented, though.
Thanks,
Michael
--
Michael Sullivan
Business Card Express of CT Thermographers to the Trade
Cheshire, CT email@hidden
_______________________________________________
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.