[alicebot-general] Setting predicates to value of a variable

Noel Bush noel at aitools.org
Fri Apr 28 07:42:08 PDT 2006


I should back up: What interpreter are you using?  And are you using 
client-side javascript, or server-side javascript?

If it's client-side javascript, then you're probably putting:

<html:script language="JavaScript">...</html:script>

in your template, right?  And if it's server-side, then you're using:

<javascript>....</javascript>

(i.e., the built-in AIML javascript tag)

In the case of server-side javascript with Program D, it looks to me 
like the context is not preserved across uses of <javascript/>, so you 
won't be able to retrieve a variable set in one call from another (I 
consider this a bug and have filed a report: 
http://bugs.aitools.org/view.php?id=123).

If you're dealing with client-side javascript, then in order to retrieve 
a value from the client side back into something on the server, you're 
going to need some "Ajax"-style stuff.  The little BotAccess class that 
comes with Program D 4.6 does not have this built in, but you could 
easily enough add:

public String set(String name, String value)
{
     return this.core.getPredicateMaster().set(name, value, this.userid, 
this.botid);
}

to org.aitools.programd.server.BotAccess, then in your bot page you 
could do this in (again, client-side) javascript:

bot.set(null, name, value);

(The null parameter is a callback function, which in this case could 
accept the return value from setting the predicate and display it 
somewhere it you want, but this is optional.)

The only problem with this is that someone could easily use it as a way 
to set *any* predicate they wanted to.  So for long-term use this needs 
some more thought security-wise, but it's a start.

Noel

Alan Haymes wrote:
> 
> Noel Bush wrote:
>> You should be able to do this:
>>
>> <set name="name"><javascript>visitor</javascript></set>
>>
>> Noel
>>
>>
> 
> Hi Noel - I tried this but "name" gets set to the string 'visitor' rather
> than the value of 'visitor'.
> --
> View this message in context: http://www.nabble.com/Setting-predicates-to-value-of-a-variable-t1523359.html#a4140493
> Sent from the Alicebot General forum at Nabble.com.
> 
> _______________________________________________
> This is the alicebot-general mailing list
> Reply to alicebot-general at list.alicebot.org
> Unsubscribe and change preferences at http://list.alicebot.org/mailman/listinfo/alicebot-general
> Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
> Learn to read at http://www.literacy.org/


More information about the alicebot-general mailing list