There were two different patches related to matching defglobals; both
have been applied in 6.1a1. Your code works fine for me in that
version, as seen in the dialog below, so maybe you've just got your
versions mixed up.
Your alternate code with a local variable has completely different
semantics: it doesn't use the local you define at the top level, but
effectively creates a new ?DJ1 for use in pattern matching.
----------------------------------------------------------------------
Jess, the Java Expert System Shell
Copyright (C) 2001 E.J. Friedman Hill and the Sandia Corporation
Jess Version 6.1a1 5/2/2002
Jess> (deftemplate foo(slot id))
(defglobal ?*DJ1* = DJ1)
TRUE
Jess> TRUE
Jess> (defrule teste
?DJ_global <- (foo(id ?*DJ1*))
=>
(printout t "GLOBAL is" ?*DJ1* crlf)
)
TRUE
Jess> (reset)
(assert (foo(id DJ1)))
(run)TRUE
Jess> <Fact-1>
Jess>
GLOBAL isDJ1
1
Jess>
----------------------------------------------------------------------
I think Alceu - UFSC/Labspot wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I'm trying to fire a rule using in the LHS a global variable. Although I've
> fixed HasLHS.java ,Jess 6.0b1 version, as reported in the answer of Steve's
> e-mail, Jess shows the message "First use of variable negated: ".
> I've tried Jess 6.1a1 binary code too, but the only way that I've found
> success is using local variable instead of global in the LHS.
> The code is like that:
>
> (deftemplate foo(slot id))
> (defglobal ?*DJ1* = DJ1)
>
> ;(bind ?DJ1 ?*DJ1*)
>
> (defrule teste
> ;?DJ_local <- (foo(id DJ1))
> ?DJ_global <- (foo(id ?*DJ1*))
> =>
> (printout t "GLOBAL is" ?*DJ1* crlf)
> )
>
> (reset)
> (assert (foo(id DJ1)))
> (run)
>
> Sorry if this subject has been discussed before.
>
> Thanks in advance,
> Alceu
>
> -----Original Message-----
> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Sexta-feira, 1 de Mar_o de 2002 11:33
> Subject: Re: JESS: First use of variable negated
>
>
> >Hi Steve,
> >
> >This is a known regression in Jess 6.0; it was first reported by Simon
> >Hamilton. It's fixed in the next release, which should be next week.
> >
> >Here's a patch for 6.0: change line 189 in jess/HasLHS.java from
> >
> > if (name.startsWith("*"))
> > ; // <--- THIS LINE
> >
> >to
> > if (name.startsWith("*"))
> > continue;
> >
> >
> >I think Steve Webster wrote:
> >[Charset iso-8859-1 unsupported, filtering to ASCII...]
> >> All,
> >>
> >> I'm encountering a "First use of variable negated" error that I can not
> find
> >> an explanation for in the documentation or this list's mail archive. In
> >> summary, when first referencing a global variable in a predicate under
> Jess
> >> 6.0, a corresponding error is thrown.
> >>
> >> The offending code is:
> >>
> >> (defglobal ?*mti* = "Recon_PhaseLine")
> >>
> >> (deftemplate foo
> >> (slot instanceName)
> >> )
> >>
> >> (defrule create-salute-report-state
> >> (foo (instanceName ?*mti*))
> >> =>
> >> (printout t "bar")
> >> )
> >>
> >> However, when I replace the predicate, "(foo (instanceName ?*mti*)),"
> with
> >> what I believe to be the equivalent, "(foo (instanceName ?i&:(eq ?i
> >> ?*mti*)))," no error results, and the clp file compiles.
> >>
> >> Given how basic this scenario is, I can not help but think I have missed
> >> something obvious. Can anyone tell me why the initial code gives an error
> on
> >> compilation?
> >>
> >> Thanks in advance for your help,
> >>
> >> Steve
> >>
> >>
> >> --------------------------------------------------------------------
> >> 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]
> >> --------------------------------------------------------------------
> >>
> >
> >
> >
> >---------------------------------------------------------
> >Ernest Friedman-Hill
> >Distributed Systems Research Phone: (925) 294-2154
> >Sandia National Labs FAX: (925) 294-2234
> >Org. 8920, MS 9012 [EMAIL PROTECTED]
> >PO Box 969 http://herzberg.ca.sandia.gov
> >Livermore, CA 94550
> >
> >--------------------------------------------------------------------
> >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]
> >--------------------------------------------------------------------
> >
> >
>
>
>
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
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]
--------------------------------------------------------------------