Note: many functions documented as requiring a specific minimum number of arguments will actually return sensible results with fewer; for example, the + function will return the value of a single argument as its result. This behavior is to be regarded as undocumented and unsupported. In addition, all functions documented as requiring a specific number of arguments will not report an error if invoked with more than that number; extra arguments are simply ignored.
The bag command does different things based on its first argument. It's really seven commands in one:
Jess> (bag create my-bag)
Jess> (defglobal ?*bag* = 0) TRUE Jess> (bind ?*bag* (bag create my-bag)) <External-Address:java.util.Hashtable> Jess> (bag set ?*bag* my-prop 3.0) 3.0 Jess> (bag get ?*bag* my-prop) 3.0
Note: the argument must follow Jess' rules for valid atoms or strings. On UNIX systems, this presents no particular problems, but Win32 filenames may need special treatment. In particular: pathnames should use either '\\' (double backslash) or '/' (forward slash) instead of '\' (single backslash) as directory separators; and pathnames which include a colon (':') or a space character (' ') must be enclosed in double quotes.
In an applet, batch will try to find the file relative to the applet's document base. In any program, if the file is not found, the name is then passed to ClassLoader.getSystemResourceAsStream(). This allows files along the class path, including files in JARs, to be batched.
(build "(defrule foo (foo) => (bar))")
Note: The string must consist of one single construct; multiple constructs can be built using multiple calls to build.
The functor call may be omitted if the method being called is non-static. The following two method calls are equivalent:
;; These are legal and equivalent (call ?vector addElement (new java.lang.String "Foo")) (?vector addElement (new java.lang.String "Foo"))Note that call may now be omitted if the object comes from the return value of another function call:
;; This is now legal ((new java.lang.Vector 10) addElement (new java.lang.String "Foo"))
Whether before or after is specified, if the code block explicitly calls return with a value, the returned value will appear to the caller to be the return value of the original function. For before advice, this means the original function will not be called in this case.
Note that it is an error for a given Java object to be installed in more than one definstance at a time. The second and subsequent definstance calls for a given object will return a fact-id with value -1.
Note: The string must consist of one single function call; multiple calls can be evaluated using multiple calls to eval.
Example:
(foreach ?x (create$ a b c d) (printout t ?x crlf))
Example:
(if (> ?x 100) then (printout t "X is big" crlf) else (printout t "X is small" crlf))
(import java.io.*)or a single class using
(import java.awt.Button)After that, all functions that can accept a Java class name (new, defclass, call, etc) will refer to the import list to try to find the class that goes with a specific name. Note that java.lang.* is now implicitly imported.
Note: See the batch command for a discussion about specifying filenames in Jess.
Note: See the batch command for a discussion about specifying filenames in Jess.
Jess> (replace$ (create$ a b c) 2 2 (create$ x y z)) (a x y z c)
Note: See the batch command for a discussion about specifying filenames in Jess.
Normally blocks (i.e., Jess stops until the applet returns), but if the last argument is an ampersand (&), the program will run in the background. The standard output and standard error streams of the process are connected to the 't' router, but the input of the process is not connected to the terminal.
Returns the Java Process object. You can call waitFor and then exitValue to get the exit status of the process.
(try (open NoSuchFile.txt r) catch (printout t (call ?ERROR toString) crlf))prints
Rete Exception in routine _open::call. Message: I/O Exception java.io.FileNotFoundException: NoSuchFile.txt.
An empty catch block is fine. It just signifies ignoring possible errors.
The code in the finally block, if present, is executed after all try and/or catch code has executed, immediately before the try function returns.