Re: default arguments/parameters
Re: default arguments/parameters
- Subject: Re: default arguments/parameters
- From: Walter Ian Kaye <email@hidden>
- Date: Wed, 8 Oct 2003 22:35:10 -0700
At 02:17p +1000 10/09/2003, Rua Haszard Morris didst inscribe upon an
electronic papyrus:
Is there a way to define a handler to take default positional parameters?
e.g.
to displayplaindialog(optional texttoshow = "default text")
display dialog texttoshow
end
Nope, unfortunately.
Is there a way to restrict the types of parameters to handlers? i.e. in the
above an error would occur if it was called with texttoshow other than text?
You can check the class and generate an error. For example:
if class of texttoshow is not in {string, integer} then
error "displayplaindialog()" & return & "texttoshow must be a string."
end if
If you'll be testing within the calling routine for specific errors
in the called subroutine, you may want to assign numbers to the
custom errors.
For example, 'error "foo" number 600'.
(I forget the exact range of numbers available; maybe 300-900??)
I get the feeling these things can be done but there is not standard
predefined way to do em, and there's no conventional way either (everyone
does it their own way).. any conventions out there?
An 'if' conditional is fairly conventional, I would guess.
-boo
friendly faces everywhere; humble folks without temptation
_______________________________________________
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.