This Pnuts User's Guide describes basic usage of Pnuts environment. Readers will learn what kind of functions are available and how to integrate Pnuts into Java applications.
This section explains some prerequisites to read the rest of the guide.
Pnuts runs on JRE (Java Runtime Environment) version 1.1 or later. The Pnuts distribution does not include JRE, which means you need to install a JRE (or JDK) in your computer before using Pnuts. If you have two or more JREs installed, you can pick one to use Pnuts every time you start a Pnuts interpreter by changing environment variables.
The pnuts.jar file is necessary to run the Pnuts interpreter. Also a shell script or a batch file is usually used to start it up. The pnuts.jar file contains standard scripts, which are described later, and classes in Pnuts API . Pnuts API is used to implement the pnuts command, in addition, developers can call them directly to incorporate the Pnuts' functionality into their applications.
Pnuts functions fall into two categories: built-in functions and others. It is important to distinguish them. Built-in functions are guaranteed to be available even when initialization script is not loaded and it is not permissible to re-define them. The Language Specification defines the built-in functions.
Module is a set of Pnuts scripts which can be utilized by applying the use() builtin function. A module corresponds to a package, in which functions of the module are defined.
The standard functions in Pnuts are grouped into pnuts::lib and pnuts::util module.
A module may depend on other modules. For example, pnuts::util module depends on pnuts::lib. When pnuts::util is loaded by use(), pnuts::lib is automatically loaded.
Custom modules of Pnuts can be made in the following steps.
use("pnuts::lib")
require("init") is needed because autoload() is not a builtin function, and it is defined in "init.pnut".require("init") autoload("play", "acme/util/cdplayer")
The User's Guide follows the following convension to show the usage of a function in a bounding box.
|
This example shows that a function called 'loadFile' takes one parameter of String type.
When a function is overloaded, the possible signatures are connected with the word ' or '.
|
When function has a optional parameter, a pair of curly brace { } is used to indicate it can be specified optionally.
When a parameter is an array type, the component type can be omitted.
|