Hi I am new to clips rule engine and have to do following in clips in mobile app (Android/Kotlin). we are using CLIPS4android library as wrapper of JNI.
How to get output from class file, when the rule gets executed by invoking the clips.run()
class RulesTest(filepath: String?) { private val clips: Environment fun stop() { clips.destroy() }
/**
* Example of how to use "assert".
* @throws CLIPSError
*/
@Throws(CLIPSError::class)
fun assertItems(products: List<Item>) {
for (product in products) {
Log.d(tag, "(Product " + "(productId " + product.ProductId + ")" + "(uomid " + product.UOMId + " )" + "(quantity " + product.Quantity + " ))")
var InsertItem: String
InsertItem = "(Product " + "(productId " + product.ProductId + ")" + "(uomid " + product.UOMId + " )" + "(quantity " + product.Quantity + " ))"
clips.assertString(InsertItem)
}
}
fun run() {
clips.eval("(facts)");
clips.run()
}
companion object {
const val tag = "CLIPSProductRulesTest"
}
init {
clips = Environment()
clips.load(filepath)
Log.d(tag, "Loading .clp...\n\n")
clips.reset()
}
}