realbasic-nug
[Top] [All Lists]

Re: Calling Functions

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Calling Functions
From: Thomas Reed <tareed at bitjuggler dot com>
Date: Mon, 31 May 2004 07:54:13 -0400
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
References: <44B54C3C-B2E6-11D8-A9EA-00039365848C at sailer-online dot de>
I thought I can call the following function

Function ErrorMessage(Message as string, Title as string)

with both calls

ErrorMessage(ErrorText)

or

ErrorMessage(ErrorText,ErrorTitle)

No, you cannot simply omit a parameter like that. There are two ways to achieve what you want. One is to give the title parameter a default value:

  Function ErrorMessage(Message as string, Title as string = "Untitled")

The other alternative is to overload the function:

  Function ErrorMessage(Message as string)
    ...
  End Function

  Function ErrorMessage(Message as string, Title as string)
    ...
  End Function

The latter makes more sense in cases where omitting the title does not imply any specific default value.
--

-Thomas

Personal web page:                  <http://homepage.mac.com/thomasareed/>
My shareware:                                 <http://www.bitjuggler.com/>
Free REALbasic code:                    <http://www.bitjuggler.com/extra/>

There are 10 kinds of people in the world -- those who understand binary
numbers and those who don't.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>