I believe you just want ONE sym-cat in your rule to concatenate ALL of the
trimmed strings into a symbol
e.g.
 
(sym-cat (call (call ?action getHost) trim) .  
              (call (call ?action getPort) trim)) .
              (call (call ?action getActionInitiator) trim)) .
          ...
)
 
OR a sym-cat wrapped around the entire set of sym-cat's (but this
is overkill).
 
It appears that sym-cat by itself does not create a symbol with the
extra spaces trimmed .. see below
 
Jess> (sym-cat (sym-cat "abcd  ") . (sym-cat "def ") . "xyz")
abcd  .def .xyz
 
So something like ...
 
Jess>  (sym-cat (sym-cat (call "abcd  " trim)) . (sym-cat (call "def " trim)) . "xyz")
abcd.def.xyz
 
OR simply
 
Jess> (sym-cat (call "abcd  " trim) .  (call "def " trim) . "xyz")
abcd.def.xyz
 
Hope this helps a bit.
 
Bob.
 
 
-----Original Message-----
From: Richard Patten [mailto:[EMAIL PROTECTED]]
Sent: Sunday, October 20, 2002 5:13 AM
To: [EMAIL PROTECTED]
Subject: Re: JESS: string manipulation in JESS

Hello again,
  Now I have changed my rule so that it looks like this,

        rule = "(defrule Fetch_StartUp\n";
        rule = rule + "(Fetch-Complete)";
        rule = rule + "=> \n" +
               "(foreach ?action (call (fetch FetchObject) getActions )\n" +
               "(assert (stat " +
               "(sym-cat(call (call ?action getHost) trim))." +
               "(sym-cat(call (call ?action getPort) trim))." +
               "(sym-cat(call (call ?action getActionInitiator) trim))." +
            ! ;   "(sym-cat(call (call ?action getOperation) trim)) " +
               "(sym-cat(call (call ?action getValue)trim)))" +
               ")))\n";  

Now I have an assert call without a function call at the head.
When I execute this I get the following

stat localhost . 1099 . ActionInitiator1 . getDataRate 100

I am using sym-cat and trim its still not working, I changed the java coding so that a "." is added to the end, then I get the following

stat localhost.  1099.  ActionInitiator1.  getDataRate. 100

What I need is this

stat localhost.1099.ActionInitiator.getDataRate.100


I seem to be unable to get rid of the white space, is there anyway to get rid of this,
thanks
Richard.

 Richard Patten <[EMAIL PROTECTED]> wrote:

I tried your method but it dosen't seem to help,

My JAVA code that looks like this.

rule = rule + "=> \n" +
               "(foreach ?action (call (fetch FetchObject) getActions )\n" +
               "(assert (stat." +
               "(sym-cat(call (call ?action getHost) trim))." +
               "(sym-cat(call (call ?action getPort) trim))." +
               "(sym-cat(call (call ?action getActionInitiator) trim))." +
               "(sym-cat(call (call ?action getOperation) trim)) " +
               "(sym-cat(call (call ?action getValue)trim)))" +! !
               ")))\n";

What I get out of this is something that looks like this

stat. localhost . 1099 . ActionInitiator1 . getDataRate 100

but what I want is

stat.localhost.1099.ActionInitiator1.getDataRate 100

could you please tell me how to get this.
thanks
Richard.

 [EMAIL PROTECTED] wrote:

I think Richard Patten wrote:
>
> Hello everybody,
> When I call a method in a java object in jess I get the following value as a return
> "localhost "
>
> What I want is just
>
> localhost
>
> without "" and the extra spaces, is there anyway that I can accomplish this in JESS.
>


1) You're getting a String back from Java, and you probably want a
symbol, which displays without quotes. You can convert a string to a
symbol using the sym-cat function.

2) You should use the java.lang.String.trim() function to remove the
spaces.

So all together, you want something like

(sym-cat (call (call ?object method) trim))

or, equivalently,

(sym-cat ((?object method) join))




---------------------------------------------------------
Ernest Friedman-Hill
D! ! istributed 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]
--------------------------------------------------------------------

 



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site

Reply via email to