[alicebot-style] Assign a value to a predicate with javascript
Anne Kootstra
anne at aiml.info
Thu Mar 23 23:53:25 PST 2006
It seems to me that this isn't a general AIML style question but one that is
particular to the Program D engine. Perhaps you can ask your question on
Alicebot.org Developer mailing list but there is also a specific Program D
mailing list at www.aitools.org <http://www.aitools.org/> .
Regards,
Anne
_____
Van: Alessandro Boca [mailto:a.boca at yahoo.it]
Verzonden: woensdag 22 maart 2006 22:02
Aan: alice-style
Onderwerp: [alicebot-style] Assign a value to a predicate with javascript
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(/</i, " lt ");
x.replace(/>/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/20060323/43f87b12/attachment.html
More information about the alicebot-style
mailing list