How do I set up my user defined class to accept an optional parameter. I have a class mails a to a predefined mailbox. I’d like to be able to override that for testing by passing in a string of a different email address. Such as:
Sub send( strOtherEmail as string )
if strOtherEmail <> “” then me.m_sendTo = strOtherEmail
call me.mailDoc.send()
End sub
strOtherEmail should be an optional parameter to send(). But as written, lotusScript always wants a parameter there.
Thanks for the help.
Jeff
Subject: Another Class Question - Passing an optional parameter.
Hi Jeff,
You can’t directly code optional parameters in your own subs and functions.
Your technique of checking strOtherMail = “” is one way to do what you want.
Another possibility would be to subclass your original class and override the send method such that your subclass simply ignores the strOtherEmail parameter. Something like this:
Class Mail
Sub send( sendTo As String )
End Sub
End Class
Class TestMail As Mail
Sub send( sendTo As String )
Mail..send( "Joe Bloggs" )
End Sub
End Class
Frunobulax