Section 2: CLIPS Overview ========================= This section gives a general overview of CLIPS and of the basic concepts used through­out this manual. 2.1 Interacting with CLIPS -------------------------- CLIPS expert systems may be executed in three ways: interactively using a simple, text-oriented, command prompt interface; interactively using a window/menu/mouse interface on certain ma­chines; or as embedded expert systems in which the user provides a main pro­gram and controls execution of the expert system. Embedded applications are dis­cussed in the *Advanced Programming Guide*. In addition, a series of commands can be automatically read di­rectly from a file when CLIPS is first started or as the result of the **batch** command. The generic CLIPS interface is a simple, interactive, text-oriented, command prompt interface for high porta­bility. The stan­dard usage is to create or edit a knowledge base using any standard text editor, save the knowledge base as one or more text files, exit the editor and execute CLIPS, then load the knowledge base into CLIPS. The in­terface provides commands for viewing the current state of the sys­tem, tracing execu­tion, adding or removing information, and clearing CLIPS. A more sophisticated window interface is available for the Macintosh, Windows 3.1, and X Window environments. All interface commands described in this section are available in the window interfaces. These interfaces are described in more detail in the *Interfaces Guide*. 2.1.1 Top Level Commands ~~~~~~~~~~~~~~~~~~~~~~~~ The primary method for interacting with CLIPS in a non-embedded environment is through the CLIPS **command prompt** (or **top level**). When the “CLIPS>” prompt is printed, a command may be entered for evaluation. Commands may be function calls, constructs, local or global variables, or constants. If a function call is entered (see section 2.3.2), that function is evaluated and its return value is printed. Function calls in CLIPS use a prefix notation—the operands to a function always appear after the function name. Entering a construct definition (see section 2.3.3) at the CLIPS prompt creates a new construct of the appropriate type. Entering a global variable (see section 2.4.3) causes the value of the global variable to be printed. Local variables can be set at the command prompt using the bind function and retain their value until a reset or clear command is issued. Entering a local variable at the command prompt causes the value of the local variable to be printed. Entering a constant (see section 2.3.1) at the top level causes the constant to be printed (which is not very useful). For example, :: CLIPS (V6.30 3/11/15) CLIPS> (+ 3 4) 7 CLIPS> (defglobal ?*x\* = 3) CLIPS> ?*x\* 3 CLIPS> red red CLIPS> (bind ?a 5) 5 CLIPS> (+ ?a 3) 8 CLIPS> (reset) CLIPS> ?a [EVALUATN1] Variable a is unbound FALSE CLIPS> The previous example first called the addition function adding the numbers 3 and 4 to yield the result 7. A global variable ?*x\* was then defined and given the value 3. The variable ?*x\* was then entered at the prompt and its value of 3 was returned. Finally the constant symbol *red* was entered and was returned (since a constant evaluates to itself). 2.1.2 Automated Command Entry and Loading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some operating systems allow additional arguments to be specified to a program when it begins execution. When the CLIPS executable is started under such an operating system, CLIPS can be made to automatically execute a series of commands read directly from a file or to load constructs from a file. The command-line syntax for starting CLIPS and automatically reading commands or loading constructs from a file is as follows: ``Syntax`` :: clips