Object Oriented Programming in Script/Sending Messages: Difference between revisions

From Sierra Wiki
Jump to navigationJump to search
sierraw>Andrew Branscom
m 1 revision imported
 
Andrew Branscom (talk | contribs)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:SCI Pages]]
[[Official SCI Documentation]]<br />
[[Official SCI Documentation]]<br />
 
[[Object Oriented Programming in Script|Table of Contents]]
&nbsp;
<div align="center">
<div align="center">
Chapter:  
Chapter:  
Line 10: Line 12:
[[Object Oriented Programming in Script/An Extended Example|6]] |  
[[Object Oriented Programming in Script/An Extended Example|6]] |  
[[Object Oriented Programming in Script/Index|Index]]
[[Object Oriented Programming in Script/Index|Index]]
</div><br />
</div>
<div align="center"><span style="font-size: 22pt">Sending Messages</span><br />''Author: [[Jeff Stephenson]]''<br />''1988-04-04''</div></div>


<div align="center"><span style="font-size: 22pt">Sending Messages</span><br />
<br />
''Author: [[Jeff Stephenson]]''<br />
==<br /> Introduction ==
''Date: 4 April 1988''</div>


&nbsp;
<blockquote>
The syntax for sending a message to an object is identical to that for a procedure call.  The object name (or an expression which evaluates to an object ID) is followed by the message selector and any parameters, all enclosed in parentheses.  There are three different kinds of messages which can be sent to objects:
</blockquote>


==<br /> Sending Messages ==
==<br /> Setting a property ==


The syntax for sending a message to an object is identical to that for a procedure call.  The object name (or an expression which evaluates to an object ID) is followed by the message selector and any parameters, all enclosed in parentheses.  There are three different kinds of messages which can be sent to objects:
<blockquote>
 
A property of an object can be set by sending a message whose message selector is the name of the property followed by a colon (':') followed by the new value of the property:
===<br /> Setting a property ===
<blockquote>A property of an object can be set by sending a message whose message selector is the name of the property followed by a colon (':') followed by the new value of the property:


<blockquote>
<blockquote>
Line 35: Line 37:
</blockquote>
</blockquote>


===<br /> Requesting the value of a property ===
==<br /> Requesting the value of a property ==
 
<blockquote>The value of a property can be obtained by sending a message with no parameters whose message selector is the name of the property followed by a question mark ('?'):
<blockquote>The value of a property can be obtained by sending a message with no parameters whose message selector is the name of the property followed by a question mark ('?'):


Line 48: Line 51:
</blockquote>
</blockquote>


===<br /> Invoking a method ===
==<br /> Invoking a method ==
 
<blockquote>
<blockquote>
A method of an object can be invoked by sending a message with any number of parameters whose message selector is the name of the method followed by a colon (':'):
A method of an object can be invoked by sending a message with any number of parameters whose message selector is the name of the method followed by a colon (':'):
Line 79: Line 83:
</blockquote>
</blockquote>


&nbsp;
==<br /> References ==
 
<references /><!-- Do not edit this section. It is autopopulated by <ref></ref> tags -->


;Notes
==<br /> Also See ==
<references />


* [[:Category:SCI Documentation|SCI Documentation]]
* [[:Category:Official SCI Documentation|Official SCI Documentation]]
* [[:Category:SCI Scripting]]
* [[:Category:Objects|Objects]]
&nbsp;
&nbsp;


[[Object Oriented Programming in Script | Table of Contents]]
[[Official SCI Documentation]]<br />
 
[[Object Oriented Programming in Script|Table of Contents]]
&nbsp;


<span style="float: left">[[Object Oriented Programming in Script/Objects|&lt; Previous: Objects]]</span>
<span style="float: left">[[Object Oriented Programming in Script/Objects|&lt; Previous: Objects]]</span>
<span style="float: right">[[Object Oriented Programming in Script/An Extended Example|Next: An Extended Example &gt;]]</span>
<span style="float: right">[[Object Oriented Programming in Script/An Extended Example|Next: An Extended Example &gt;]]</span>
&nbsp;
&nbsp;
 
[[Category:References]]
[[Category:SCI References]]
[[Category:Historical Pages]]
[[Category:SCI Historical Pages]]
[[Category:Development]]
[[Category:SCI Development]]
[[Category:Documentation]]
[[Category:SCI Documentation]]
[[Category:SCI Documentation]]
[[Category:Official Documentation]]
[[Category:Official SCI Documentation]]
[[Category:Examples]]
[[Category:SCI Examples]]
[[Category:Scripting]]
[[Category:SCI Scripting]]
[[Category:Scripting]]
[[Category:Scripting]]
[[Category:SCI Scripting]]

Latest revision as of 14:22, 2 January 2026

Official SCI Documentation
Table of Contents  

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | Index

Sending Messages
Author: Jeff Stephenson
1988-04-04



Introduction

The syntax for sending a message to an object is identical to that for a procedure call. The object name (or an expression which evaluates to an object ID) is followed by the message selector and any parameters, all enclosed in parentheses. There are three different kinds of messages which can be sent to objects:


Setting a property

A property of an object can be set by sending a message whose message selector is the name of the property followed by a colon (':') followed by the new value of the property:

Code:
(ego x:23) or (ego x: 23)

sets the x property of ego to 23.


Requesting the value of a property

The value of a property can be obtained by sending a message with no parameters whose message selector is the name of the property followed by a question mark ('?'):

Code:
(ego x?)

will return the value of the x property of ego.


Invoking a method

A method of an object can be invoked by sending a message with any number of parameters whose message selector is the name of the method followed by a colon (':'):

Code:
(ego moveTo: x y) or (ego moveTo:x y)

tells ego to move to coordinates x and y by invoking the moveTo method of ego.


Any number of messages can be sent in one fell swoop:

Code:
(ego
     x:50
     y:50
     setMotion: MoveTo 100 100
     setCycle: Reverse self
)

will position ego at coordinates (50, 50), start him moving to coordinates (100, 100), and set him to cycle in reverse cel order. When multiple messages are sent to an object, the messager in the kernel sends them one at a time in left to right order. In multiple message sends, all parameters are evaluated before the messages are sent.


References



Also See

 

Official SCI Documentation
Table of Contents

< Previous: Objects Next: An Extended Example >