[alicebot-style] Assign a value to a predicate with javascript

Alessandro Boca a.boca at yahoo.it
Wed Mar 22 13:02:12 PST 2006


Hi everybody,

I have a problem that i can't solve using Program D. This problem involves predicates and the <javascript> tag.

What I would like to do is to pass the value of a predicate to a javascript function, manipulate this value and get it back in another predicate.

I post an example below:

<category>
 <pattern>PRINT *</pattern>
 <template>
  <think>
   <set name="x"><star/></set>
   <set name="y">
    <javascript>
     function replacestring(s){
     var x=s;
     x.replace(/&lt;/i, " lt ");
     x.replace(/&gt;/i, " gt ");
     return x; }
     replacestring('<get name="x"/>');
    </javascript>
   </set>
  </think>
 </template>
</category>

In this example I get a value from the user and put it in a predicate called x and after that I try to put the value of y in a predicate called y, after having replaced all the < and > of the predicate with the values lt and gt.

In this example I don't get any error from the Javascript interpreter and I think that the code is quite correct and it should work, but at the end the predicate y is empty.

I think that this isn't the correct way to assign values from the javascript but, if I can't use the return, how can I assign the value?

Thank you everybody for your help.

Ale
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.alicebot.org/pipermail/alicebot-style/attachments/20060322/bb13e6ca/attachment.html


More information about the alicebot-style mailing list