Messages with arguments
Many operations are designed to be as general
purpose as possible. One way this is achieved is by having an operation that can change
what it does according to some values passed to it along as part of a message. For
example, an operation to increase the balance of a bank account would probably be designed
to expect a particular value of how much to deposit. The sending of such a message might
be in the form:
- send message depositMoney( 101.54 ) to object bankAccount123
In the above example a particular object (bank
account number 123) is to be credited with ?01.54. The value "101.54" is
called an argument (also sometime called a parameter). Messages can include zero, one or
many arguments. Other example of possible message with arguments include:
- send message setRadius( 200 ) to object
circle1
- send message setWindowPosition( 100, 200 ) to object notepadApplication1
- send message retrieveHTMLPage("www.mdx.ac.uk/index.HTML") to object browserWindow2
You actually have a lot of
experience of sending messages with arguments through your interaction with almost all
Windows programs. For example, In a text editor or word processor when you wish to save a
file with a new name and select the ‘Save File As’ menu choice, you are
presented with a dialog window in which you enter/choose the file name and location. The
dialog window object will then send a message with your choices (as arguments) back to the
application, and the application will write the file to disk. In the figure below a file
is being saved from the Notepad accessory application:
A reply such as the following is
returned to the application from this file dialogue object:
return to object notepadApplication1
the reply ["c:\temp\", "menu1", textDocument]
Back
to top

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg
|