next up previous

13.1.10 Calling the Operating System

The system function allows a call to the operating system. It is patterned after the system function provided to C on most UNIX systems. This function has no return value.

Syntax

(system <lexeme-expression>*)

Example

(defrule print-directory
   (print-directory  ?directory)
   =>
   (system "dir " ?directory));      Note space => "dir<space>"

Note that any spaces needed for a proper parsing of the system command must be added by the user in the call to system. Also note that the system command is not guaranteed to execute (e.g., the operating system may not have enough memory to spawn a new process).


Portability Note

Not all operating systems/compilers provide this function. The code is stored in the sysdep.c file, and the default coding for generic CLIPS is a nonfunctional stub that will compile on any machine. On some machines (such as an IBM PC running DOS), there may be insufficient memory available to spawn a subprocess to execute the system command. In such a case, the command will not be executed and the system command will return with no action taken.


next up previous