Methods and procedures are code blocks with the functionality of receiving parameters and returning values. They are essential to every SCI game, and used throughout the entire execution of the game.
All code is either in a method or a procedure. Both have the same functionality, but procedures are not tied to objects. Methods are always members of an object.
Methods give objects functionality and the ability to perform tasks. They can take a virtually unlimited amount of parameters, and have the option of returning a value.
Every object in the template game has methods whether you realize it or not. This is because the base object, "obj", contains a number of them. If a class is derived from another class, it can be called with it's superclass' methods, even if they are not defined in the actual object.
Code:( method (changeScore addScore)
= gScore + gScore addScore
(if(> addScore 0 )
(scoreSound:playMaybe())
)
)This example is a method called "changeScore" with one parameter, labeled "addScore".
For more information on methods, have a look at the section in the SCI Studio help File.
Procedures are just like methods, but are not part of an object. They can take a virtually unlimited amount of parameters, and have the option of returning a value.
Though procedures can be built specifically for use with objects, they generally are not.
Code:(procedure public (IsPosOrNeg aNumber )
(if(< aNumber 0)
return( -1)
)
return(> aNumber 0)
)This example is a procedure called "IsPosOrNeg" with one parameter, labeled "aNumber".
For more information on procedures, have a look at the section in the Procedures section from the SCI Studio Help File.
You should now have a general idea on what methods and procedures are. If you don't fully understand them yet, don't worry. Continue on with the tutorial, doing the step by step examples. When done, you should have a good grasp on them. If you still do not, come back to this chapter and read it again, and look at the links to the help file.
< Previous: Chapter 11 - Variables Next: Chapter 13 - Conditional and Looping Statements >Top
You can help keep The Sierra Help Pages and its affiliates alive by helping to defray some of the costs of hosting this site. If it has been of help to you, please consider contributing to help keep it online.Thank you.
The Sierra Help Pages | Sierra Game Help | Walkthroughs | Hints, Tips & Spoilers | Utilities | Links | SHP Forums | Search
© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.