Objects in webscript – Apple WebObjects 3.5 User Manual

Page 165

Advertising
background image

165

To speed the development cycle, you may want to write your application in
a scripting language. The WebObjects scripting language is called
WebScript. You can write all or part of your WebObjects application in
WebScript.

This chapter tells you everything you need to know to use the WebScript
language: its syntax and language constructs. WebScript is very similar to
Objective-C. If you already know Objective-C, you may want to just scan
this chapter and pay special attention to the section “WebScript for
Objective-C Developers” (page 183), which describes the differences
between WebScript and Objective-C.

WebScript is an object-oriented programming language. This chapter
attempts to give you a brief introduction to the object-oriented concepts
you’ll need to know to follow the discussion, but it by no means teaches you
object-oriented programming. To learn object-oriented programming, there
are several books you can read, such as Object-Oriented Programming and the
Objective-C Language
.

Objects in WebScript

In WebScript, you work entirely with objects. An object is composed of data
(called instance variables) and a set of actions that act upon that data (called
methods). All variables that you declare are objects, and all values that a
method returns are objects. There are no simple data types like

int

or

char

in C.

Each file that you write in WebScript defines an object. The definition of an
object is called a class. A class specifies the instance variables that will be
created for each object and the methods that the object will be able to
perform. To create an object, you create an instance of a class (or instantiate a
class).

For example, the following is a typical WebScript file. (This is actually the
script file for the Visitors example’s Main component. You can look at the
entire Visitors example in

<DocRoot>/WebObjects/Examples/WebScript/Visitors.woa

.)

Advertising