Back: 1.1.1 Defining a variable Forward: 1.1.3 Printing an expression     FastBack: 1. Basic Ideas Up: 1.1 Simple Statements FastForward: 2. Using Array Syntax         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document

1.1.2 Invoking a procedure

A Yorick function which has side effects may sensibly be invoked as a procedure, discarding the value returned by the function, if any:

 
plg, sin(theta)*exp(-theta/6), theta
write, file, theta, sin(theta)*exp(-theta/6)
close, file

The plg function plots a graph on your screen — in this case, three cycles of a damped sine wave. The graph is made by connecting 200 closely spaced points by straight lines.

The write function writes a two column, 200 line table of values of the same damped sine wave to the file ‘damped.txt’. Then close closes the file, making it unavailable for any further write operations.

A line which ends with a comma will be continued, to allow procedures with long argument lists. For example, the write statement could have been written:

 
write, file, theta,
             sin(theta)*exp(-theta/6)

A procedure may be invoked with zero arguments; several graphics functions are often used in this way:

 
hcp
fma

The hcp function writes the current graphics window contents to a “hardcopy file” for later retrieval or printing. The fma function stands for “frame advance” — subsequent plotting commands will draw on a fresh page. Normally, plotting commands such as plg draw on top of whatever has been drawn since the previous fma.


Back: 1.1.1 Defining a variable Forward: 1.1.3 Printing an expression     FastBack: 1. Basic Ideas Up: 1.1 Simple Statements FastForward: 2. Using Array Syntax         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document