next up previous contents index
Next: Basic Picture Concepts Up: A Sample File Previous: A Sample File   Contents   Index

Command Syntax

Attribute-setting and drawing commands are C++ functions, blocks of instructions that can be invoked--or called--by name. Like mathematical functions, C++ functions accept arguments as input and return values. Each argument has a type, such as integer (int), real number (double, for ``double-precision floating point''), or P (ePiX point), and may be hard-coded or specified symbolically. C++ is a ``typed'' language, meaning that the compiler checks function calls for the proper type and number of arguments, and issues an error if no matching function is found.

C++ allows functions to be given default arguments; when a function has defaults, the corresponding argument(s) may be omitted in a call. A command is usually described by listing the types and names of the arguments. For brevity, the type double may be left tacit. Default arguments are denoted by square brackets. The command

  line(P pt1, P pt2, [double stretch], [int n]);
defines a ``line'' command that accepts two mandatory arguments of type P, an optional real-valued stretch parameter, and an optional integer n. When a function is called in an input file, arguments' types are not given:
  line(P(-2,1), P(1,0), 6.4);
The last argument is assigned its default value in this case.


next up previous contents index
Next: Basic Picture Concepts Up: A Sample File Previous: A Sample File   Contents   Index
Andrew D. Hwang 2004-09-04