Reserved words – Apple WebObjects 3.5 User Manual

Page 178

Advertising
background image

Chapter 10

The WebScript Language

178

The postincrement and postdecrement operators are not supported. They
behave like the preincrement and predecrement operators. For example:

// WATCH OUT!! Probably not what you want.
i = 0;
while (i++ < 1) {

//this loop never gets executed because i++ is a preincrement.

}

Reserved Words

WebScript includes the following reserved words:

if

else

for

while

id

break

continue

self

super

nil

YES

NO

Three reserved words are special kinds of references to objects:

self

,

super

, and

nil

.

You can use these reserved words in any method.

self

refers to the object (the WOApplication object, the WOSession object, or the

WOComponent object) associated with a script. When you send a message to

self

, you’re telling the object associated with the script to perform a method that’s

implemented in the script. For example, suppose you have a script that
implements the method

giveMeARaise

. From another method in the same script,

you could invoke

giveMeARaise

as follows:

[self giveMeARaise];

This tells the WOApplication, WOSession, or WOComponent object associated
with the script to perform its

giveMeARaise

method.

When you send a message to

self

, the method doesn’t have to be physically

located in the script file. Remember that part of the advantage of object-
oriented programming is that a subclass automatically implements all of its
superclass’s methods. For example, WOComponent defines a method named

application

, which retrieves the WOApplication associated with this component.

Thus, you can send this message in any of your components to retrieve the
application object:

Advertising