In dynamic-chain-search-2, you're not giving the rule a chance to fire
before reading the defglobal...

I think Matthew J Hutchinson wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> G'day everyone,
> 
> I am frustratingly close to getting some Jess code completed that has
> already taken me waayyy too long. Originally in the code snippet below, I
> was using hard-coded global variables and things worked well. But then I
> switched to using the gensym* so that the functions would be safe from a
> concurrency perspective.
> 
> I noticed that each time the RHS is activated (I know the rules activate
> too) the appropriate methods are not called. It seems that maybe the
> variables are no longer existing? However, the I made the rule refer to a
> global variable.
> 
> ------- CODE ------------
> 
> (deffunction dynamic-chain-search-1 (?p1 ?p2 ?p3 ?p4 ?p5 ?p6 ?p7)
>     (bind ?g (sym-cat "?*"(gensym*)"*") )
>     (bind ?v (str-cat "(defglobal "?g" = (new ArrayCombine))"))
>     (build ?v)
>     (bind ?d1 (str-cat "(defrule "(gensym*)" ("?p1" ("?p2" \""?p3"\") ("?p4"
> ?q)) => (call "?g" addArray (dynamic-chain-search-2 "?p5" "?p6" ?q "?p7"))
> )"))
>        (printout t ?d1 crlf)
>     (build ?d1)
>     (run)
>     (return (call (eval ?g) getCombinedArray) )
>     )
> 
> (deffunction dynamic-chain-search-2 (?p1 ?p2 ?p3 ?p4)
>     (bind ?gs (sym-cat "?*"(gensym*)"*") )
>     (bind ?v1 (str-cat "(defglobal "?gs" = (new ArrayList 0))"))
>     (build ?v1)
>     (printout t "using dyanmic-chain-search-2" crlf)
>     (bind ?s1 (str-cat "(defrule "(gensym*)" ("?p1" ("?p2" \""?p3"\") ("?p4"
> ?qwerty)) => (call "?gs" add ?qwerty)  )"))
>     ;(bind ?s1 (str-cat "(defrule "(gensym*)" ("?p1" ("?p2" \""?p3"\")
> ("?p4" ?qwerty)) => (printout t \"fired!\" ?qwerty crlf)  )"))
>     (build ?s1)
>     (return (eval ?gs))
>     )
> ----------------------------------------------
> 
> (The ArrayCombine class is my own creation, but I know it works. )
> 
> 
> NOTICE though, that the rule that is built is:
> 
> (defrule gen2 (post_codes (post_code "6014") (locality ?q)) => (call ?*gen1*
> addArray (dynamic-chain-search-2 street_name_alias locality ?q
> actual_name))  )
> 
> And we can plainly see it refers to a global variable - which makes me
> wonder why it's not working...
> 
> 
> Thanks so much!
> Matt
> 
> 
> 
> --
> Matthew Hutchinson
> Ph.D. Candidate
> Department of Spatial Sciences
> Curtin University of Technology
> GPO Box U1987
> Perth, Western Australia 6845
> 
> Visiting Scholar
> Department of Geography and Planning
> University of Akron
> Akron, Ohio USA



---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to