JESS: JESS Simple Variable Question

View: New views
6 Messages — Rating Filter:   Alert me  

JESS: JESS Simple Variable Question

by John Chrysakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello to all community,

I am trying to bind an int variable e.g slide
and then to use it's value plus a different number,

e.g slide + 2, slide +3.

How I Can Do that, the following doesn't work.


(defrule Rule1
      ...
    =>
     (bind ?slide 4)
     (calling goToSlide "p1" ?slide)
     (calling goToSlide "p2" ((?slide)+1))
     (calling goToSlide "p3" ((?slide)+6))
        ...
    )


thank you in advance!


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: JESS Simple Variable Question

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In Jess, parentheses always have special meaning; most of the time,  
they mean "this is a function call". So (?slide) would mean "call  
what's in ?slide as a function", which is definitely not what you  
want. The "+" function, like all Jess functions, is called using  
prefix notation; the quantity "three more than ?slide" is written (+ ?
slide 3) .



On Aug 18, 2009, at 9:24 AM, John Chrysakis wrote:

>
> Hello to all community,
>
> I am trying to bind an int variable e.g slide
> and then to use it's value plus a different number,
>
> e.g slide + 2, slide +3.
>
> How I Can Do that, the following doesn't work.
>
>
> (defrule Rule1
>      ...
>    =>
>     (bind ?slide 4)
>     (calling goToSlide "p1" ?slide)
>     (calling goToSlide "p2" ((?slide)+1))
>     (calling goToSlide "p3" ((?slide)+6))
> ...
>    )
>
>
> thank you in advance!
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users  
> you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...
> .
> --------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            ejfried@...
Livermore, CA 94550                             http://www.jessrules.com





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: JESS Simple Variable Question

by jo-48 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think  you want this?

( + ?slide 1)




----- Original Message ----
From: John Chrysakis <hrysakis@...>
To: jess-users@...
Sent: Tuesday, August 18, 2009 3:24:25 PM
Subject: JESS: JESS Simple Variable Question


Hello to all community,

I am trying to bind an int variable e.g slide
and then to use it's value plus a different number,

e.g slide + 2, slide +3.

How I Can Do that, the following doesn't work.


(defrule Rule1
      ...
    =>
     (bind ?slide 4)
     (calling goToSlide "p1" ?slide)
     (calling goToSlide "p2" ((?slide)+1))
     (calling goToSlide "p3" ((?slide)+6))
    ...
    )


thank you in advance!


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


     


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: JESS Simple Variable Question

by John Chrysakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I used: (calling goToSlide "TEST" + ? slide 1)

but I am getting:

Jess reported an error in routine Value.intValue
        while executing (calling goToSlide + ?slide 1)
        while executing defrule MAIN::SettingStateAccordingToRoom-rule1.
  Message: '+' is a symbol, not  an integer.

...
On Tue, 18 Aug 2009, Ernest Friedman-Hill wrote:

> In Jess, parentheses always have special meaning; most of the time,
> they mean "this is a function call". So (?slide) would mean "call
> what's in ?slide as a function", which is definitely not what you
> want. The "+" function, like all Jess functions, is called using
> prefix notation; the quantity "three more than ?slide" is written (+ ?
> slide 3) .
>
>
>
> On Aug 18, 2009, at 9:24 AM, John Chrysakis wrote:
>
> >
> > Hello to all community,
> >
> > I am trying to bind an int variable e.g slide
> > and then to use it's value plus a different number,
> >
> > e.g slide + 2, slide +3.
> >
> > How I Can Do that, the following doesn't work.
> >
> >
> > (defrule Rule1
> >      ...
> >    =>
> >     (bind ?slide 4)
> >     (calling goToSlide "p1" ?slide)
> >     (calling goToSlide "p2" ((?slide)+1))
> >     (calling goToSlide "p3" ((?slide)+6))
> > ...
> >    )
> >
> >
> > thank you in advance!
> >
> >
> > --------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users
> > you@...'
> > in the BODY of a message to majordomo@..., NOT to the list
> > (use your own address!) List problems? Notify owner-jess-users@...
> > .
> > --------------------------------------------------------------------
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfried@...
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@....
> --------------------------------------------------------------------
>
>


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: JESS Simple Variable Question

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, as I said, it would  be

(calling goToSlide "TEST" (+ ? slide 1))

On Aug 19, 2009, at 4:43 AM, John Chrysakis wrote:

>
> Hi,
>
> I used: (calling goToSlide "TEST" + ? slide 1)
>
> but I am getting:
>
> Jess reported an error in routine Value.intValue
> while executing (calling goToSlide + ?slide 1)
> while executing defrule MAIN::SettingStateAccordingToRoom-rule1.
>  Message: '+' is a symbol, not  an integer.
>
> ...
> On Tue, 18 Aug 2009, Ernest Friedman-Hill wrote:
>
>> In Jess, parentheses always have special meaning; most of the time,
>> they mean "this is a function call". So (?slide) would mean "call
>> what's in ?slide as a function", which is definitely not what you
>> want. The "+" function, like all Jess functions, is called using
>> prefix notation; the quantity "three more than ?slide" is written  
>> (+ ?
>> slide 3) .
>>
>>
>>
>> On Aug 18, 2009, at 9:24 AM, John Chrysakis wrote:
>>
>>>
>>> Hello to all community,
>>>
>>> I am trying to bind an int variable e.g slide
>>> and then to use it's value plus a different number,
>>>
>>> e.g slide + 2, slide +3.
>>>
>>> How I Can Do that, the following doesn't work.
>>>
>>>
>>> (defrule Rule1
>>>     ...
>>>   =>
>>>    (bind ?slide 4)
>>>    (calling goToSlide "p1" ?slide)
>>>    (calling goToSlide "p2" ((?slide)+1))
>>>    (calling goToSlide "p3" ((?slide)+6))
>>> ...
>>>   )
>>>
>>>
>>> thank you in advance!
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users
>>> you@...'
>>> in the BODY of a message to majordomo@..., NOT to the list
>>> (use your own address!) List problems? Notify owner-jess-users@...
>>> .
>>> --------------------------------------------------------------------
>>
>> ---------------------------------------------------------
>> Ernest Friedman-Hill
>> Informatics & Decision Sciences          Phone: (925) 294-2154
>> Sandia National Labs
>> PO Box 969, MS 9012                            ejfried@...
>> Livermore, CA 94550                             http://www.jessrules.com
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users you@...
>> '
>> in the BODY of a message to majordomo@..., NOT to the list
>> (use your own address!) List problems? Notify owner-jess-users@...
>> .
>> --------------------------------------------------------------------
>>
>>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users  
> you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@...
> .
> --------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------


Re: JESS: JESS Simple Variable Question

by John Chrysakis :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


OK thanks Ernest for your help!



On Wed, 19 Aug 2009, Ernest Friedman-Hill wrote:

> Yes, as I said, it would  be
>
> (calling goToSlide "TEST" (+ ? slide 1))
>
> On Aug 19, 2009, at 4:43 AM, John Chrysakis wrote:
>
> >
> > Hi,
> >
> > I used: (calling goToSlide "TEST" + ? slide 1)
> >
> > but I am getting:
> >
> > Jess reported an error in routine Value.intValue
> > while executing (calling goToSlide + ?slide 1)
> > while executing defrule MAIN::SettingStateAccordingToRoom-rule1.
> >  Message: '+' is a symbol, not  an integer.
> >
> > ...
> > On Tue, 18 Aug 2009, Ernest Friedman-Hill wrote:
> >
> >> In Jess, parentheses always have special meaning; most of the time,
> >> they mean "this is a function call". So (?slide) would mean "call
> >> what's in ?slide as a function", which is definitely not what you
> >> want. The "+" function, like all Jess functions, is called using
> >> prefix notation; the quantity "three more than ?slide" is written
> >> (+ ?
> >> slide 3) .
> >>
> >>
> >>
> >> On Aug 18, 2009, at 9:24 AM, John Chrysakis wrote:
> >>
> >>>
> >>> Hello to all community,
> >>>
> >>> I am trying to bind an int variable e.g slide
> >>> and then to use it's value plus a different number,
> >>>
> >>> e.g slide + 2, slide +3.
> >>>
> >>> How I Can Do that, the following doesn't work.
> >>>
> >>>
> >>> (defrule Rule1
> >>>     ...
> >>>   =>
> >>>    (bind ?slide 4)
> >>>    (calling goToSlide "p1" ?slide)
> >>>    (calling goToSlide "p2" ((?slide)+1))
> >>>    (calling goToSlide "p3" ((?slide)+6))
> >>> ...
> >>>   )
> >>>
> >>>
> >>> thank you in advance!
> >>>
> >>>
> >>> --------------------------------------------------------------------
> >>> To unsubscribe, send the words 'unsubscribe jess-users
> >>> you@...'
> >>> in the BODY of a message to majordomo@..., NOT to the list
> >>> (use your own address!) List problems? Notify owner-jess-users@...
> >>> .
> >>> --------------------------------------------------------------------
> >>
> >> ---------------------------------------------------------
> >> Ernest Friedman-Hill
> >> Informatics & Decision Sciences          Phone: (925) 294-2154
> >> Sandia National Labs
> >> PO Box 969, MS 9012                            ejfried@...
> >> Livermore, CA 94550                             http://www.jessrules.com
> >>
> >>
> >>
> >>
> >>
> >> --------------------------------------------------------------------
> >> To unsubscribe, send the words 'unsubscribe jess-users you@...
> >> '
> >> in the BODY of a message to majordomo@..., NOT to the list
> >> (use your own address!) List problems? Notify owner-jess-users@...
> >> .
> >> --------------------------------------------------------------------
> >>
> >>
> >
> >
> > --------------------------------------------------------------------
> > To unsubscribe, send the words 'unsubscribe jess-users
> > you@...'
> > in the BODY of a message to majordomo@..., NOT to the list
> > (use your own address!) List problems? Notify owner-jess-users@...
> > .
> > --------------------------------------------------------------------
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences, Sandia National Laboratories
> PO Box 969, MS 9012, Livermore, CA 94550
> http://www.jessrules.com
>
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you@...'
> in the BODY of a message to majordomo@..., NOT to the list
> (use your own address!) List problems? Notify owner-jess-users@....
> --------------------------------------------------------------------
>
>


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------