| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (2 out of 25)

Introduction

A procedure is a predefined sequence of operations that execute sequentially and/or in parallel each time the procedure is invoked. Procedures are convenient when you want to perform the same operations repeatedly under different circumstances and/or on different data values. For a comparison of procedures and rules, see Procedures and Rules.

G2 executes a procedure when the procedure's name and arguments (if any) appear in a call statement or a start action. The procedure executes synchronously when called and asynchronously when started. A called procedure can return one or more values, which are obtained by including the invoking call statement in an assignment statement.

A procedure that returns a value is not the same as a G2 function. Functions have a simpler syntax and are less powerful than procedures, but can be invoked by embedding references to them directly into expressions. Complete information on G2 functions appears in Chapter 25, Functions.

This chapter shows you how to define, use, and debug user-supplied G2 procedures. Several other documents and chapters in this document supply related information about procedures:

Methods have the same syntax as procedures, but are defined and invoked differently. Complete information on creating and using methods appears in Chapter 22, Methods.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (2 out of 25)

Copyright © 1997 Gensym Corporation, Inc.