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.
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
;; 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"))
(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.
Modifying a definstance fact will cause the appropriate object properties to be set as well.
Jess> (replace$ (create$ a b c) 2 2 (create$ x y z)) (a x y z c)
(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.