You could (defglobal ?*ans* = 0) and add this to the rule where you compute ?ans1: (bind ?*ans*?ans1)
But "accessing from any other defrule" is somewhat vague. If this means that the computed "ans" value should participate in some match with other facts, you might consider creating a single fact (let's call its template Result) with an "ans" slot and update this fact accordingly. You can pull in this fact into your rule secbudget by extending the LHS, or you could keep a reference to this fact in a global variable, set to the result of the assert call adding the Result singleton to your WM. On Thu, Feb 5, 2009 at 6:21 AM, VishalGoradia <[email protected]>wrote: > > Hello everyone, > > This is my first post to the forum. Also, I am working on my first project > is jess. I hereby provide a part of my code i am having difficulties with. > > > (deftemplate securitylevel > (slot budgetscore) > (slot metricnumber) > ) > > (deftemplate security_budget > (slot secbudget) > (slot techbudget) > ) > > (defrule secbudget > (and (security_budget (secbudget ?sb)(techbudget ?tb))) > => > (bind ?ans (/ ?sb ?tb)) > (bind ?ans1 (* ?ans 100)) > (printout t "Security Budget level achieved " ?ans1 "%"crlf)) > ;;;;;;; now here i wish to save the ans1 value in some variable which can > be > accessed, modified and displayed from any other defrule > > > Earlier I thought of creating one more slot in securitylevel template to > save the ans1 value and thus can be accessed from any other defrule. But I > did not work. Also, since i need to display it, after modifying it dint > work > for me. > > Can anyone help me with this? > > Thanks in advance. > Vishal > -- > View this message in context: > http://www.nabble.com/storing-and-printout-a-global-variable-tp21845524p21845524.html > Sent from the Jess mailing list archive at Nabble.com. > > > > -------------------------------------------------------------------- > To unsubscribe, send the words 'unsubscribe jess-users [email protected]' > in the BODY of a message to [email protected], NOT to the list > (use your own address!) List problems? Notify [email protected]. > -------------------------------------------------------------------- > >
