<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML> <Object ID = agentcontrol codebase = # version = 2, 0, 0 Height = 0 width = 0
Classid = CLSID: D45FD31B-5C6E-11D1-9EC1-00C04FD7081F> </Object>
<Object ID = L & amp; htruvoice codebase = # version = 6, 0, 0 Height = 0 width = 0
Classid = CLSID: B8F2846E-CE36-11D0-AC83-00C04FD97575> </Object>
<Script language = JavaScript>
<! --//
// * Character objects
VaR Merlin;
// * Variables
VaR usedchars;
VaR merlinid;
VaR merlinacs;
VaR merlinurl;
VaR merlinstates;
VaR merlinanimations;
VaR merlinreq;
VaR merlinstatesreq;
VaR merlinanimationsreq;
VaR merlinloaded;
VaR loadreq;
VaR hidereq;
VaR merlinleftx, merlincenterx, merlinrightx;
VaR merlintopy, merlincentery, merlinbottomy;
// * Initialize
Usedchars = "Merlin ";
// * Merlin
Merlinid = "Merlin ";
Merlinacs = "Merlin. ACS ";
// Merlinurl = "http://agent.microsoft.com/agent2/chars/merlin/merlin.acf ";
Merlinurl = "#"
Merlinstates = "showing, hiding, speaking, moving, gesturing, idling, hearing, listening ";
Merlinanimations = "gestureleft, surprised ";
Merlinloaded = false;
Window_onload ();
Function window_onload (){
// Purpose: to automatically run the program when the page is opened
// * Insert any NON-AGENT related scripting here
Agentcontrol. Connected = true;
Merlinloaded = loadlocalagent (merlinid, merlinacs );
If (merlinloaded ){
Setcharobj ();
}
Checkloadstatus ();
}
Function loadlocalagent (charid, characs ){
// Purpose: attempts to load the specified character
// Returns: true if successful, false if not
Agentcontrol. raiserequesterrors = false;
Loadreq = agentcontrol. characters. Load (charid, characs );
Agentcontrol. raiserequesterrors = true;
If (loadreq. status! = 1 ){
Return (true );
}
Return (false );
}
Function setcharobj (){
// Purpose: sets the character reference and TTS language ID
Merlin = agentcontrol. characters. character (merlinid );
Merlin. languageid = 0x409;
}
Function checkloadstatus (){
// Purpose: determines if required characters have been loaded.
// If not, issue request to load next character
// Else run the agentintro routine
If (! Merlinloaded ){
Window. Status = "loading" + merlinid + "character. Please wait ...";
Merlinreq = agentcontrol. characters. Load (merlinid, merlinurl );
Return (false );
}
Window. Status = "";
Agentintro ();
Return (true );
}
Function loaderror (){
VaR strmsg;
Window. Status = "";
Strmsg = "error loading character:" + merlinid + "/N ";
Strmsg = strmsg + "This Microsoft Agent script requires the character (s):/N ";
Strmsg = strmsg + usedchars;
Alert (strmsg );
}
Function getscreenpositions (){
VaR screenwidth = Window. Screen. width;
VaR screenheight = Window. Screen. height;
If (screenwidth = 0) | (screenheight = 0 )){
Screenwidth = 800;
Screenheight = 600;
}
Merlincenterx = (parseint (screenwidth/2)-parseint (Merlin. width/2 ));
Merlinrightx = (screenwidth-Merlin. width );
Merlincentery = (parseint (screenheight/2)-parseint (Merlin. Height/2 ));
Merlinbottomy = (screenheight-Merlin. Height );
}
Function initagentcommands (){
// Purpose: Initialize the commands menu
Merlin. commands. removeall ();
Merlin. commands. Caption = "my menu name ";
Merlin. commands. Add ("ACO", "Advanced Character options", "Advanced Character options ");
}
Function agentintro (){
Getscreenpositions ();
Initagentcommands ();
Merlin. moveTo (merlinleftx, merlintopy );
Merlin. Show ();
Merlin. Speak ("Hello I 'am greystar! ");
Merlin. Think ("what do you want to know? ");
Merlin. Play ("gestureleft ");
Merlin. Speak ("Help yourself to read! ");
Merlin. Play ("surprised ");
Merlin. Hide ();
}
// -->
</SCRIPT>
<Script language = JavaScript event = requestcomplete (requestobject)
For = agentcontrol>
<! --//
// Purpose: take action on completion or failure of requests
{
Switch (requestobject ){
Case merlinreq:
If (requestobject. Status = 0 ){
Setcharobj ();
If (merlinstates! = ""){
Window. Status = "loading" + merlinid + "states. Please wait ...";
Merlinstatesreq = agentcontrol. characters (merlinid). Get ("State", merlinstates, true );
}
Else if (merlinanimations! = ""){
Window. Status = "loading" + merlinid + "animations. Please wait ...";
Merlinanimationsreq = agentcontrol. characters (merlinid). Get ("Animation", merlinanimations, true );
}
Else {
Merlinloaded = true;
Checkloadstatus ();
}
}
Else {
Loaderror ();
}
Break;
Case merlinstatesreq:
If (requestobject. Status = 0 ){
If (merlinanimations! = ""){
Window. Status = "loading" + merlinid + "animations. Please wait ...";
Merlinanimationsreq = agentcontrol. characters (merlinid). Get ("Animation", merlinanimations, true );
}
Else {
Merlinloaded = true;
Checkloadstatus ();
}
}
Else
{
Loaderror ();
}
Break;
Case merlinanimationsreq:
If (requestobject. Status = 0)
{
Merlinloaded = true;
Checkloadstatus ();
}
Else
{
Loaderror ();
}
Break;
Case hidereq:
Agentcontrol. characters. Unload (merlinid );
Break;
} // End Switch
}
// -->
</SCRIPT>
<Script language = JavaScript event = command (userinput) for = agentcontrol>
<! --//
// Purpose: Determine command that was selected either by menu or voice
// And run the applicable Command Script
VaR badconfidence;
Badconfidence = 10;
If (userinput. Confidence <=-40)
{
// Bad Recognition
}
Else if (userinput. alt1name! = "") & (Math. Abs (math. Abs (userinput. alt1confidence)-math. Abs (userinput. Confidence) <badconfidence ))
{
// Bad confidence-Too close to another command
}
Else if (userinput. alt2name! = "") & (Math. Abs (math. Abs (userinput. alt1confidence)-math. Abs (userinput. Confidence) <badconfidence ))
{
// Bad confidence-Too close to another command
}
Else
{
// High confidence
Switch (userinput. Name ){
Case "ACO ":
Agentcontrol. propertysheet. Visible = true;
Break;
}
}
// -->
</SCRIPT>
<Script language = JavaScript event = bookmark (bookmarkid) for = agentcontrol>
<! --//
// -->
</SCRIPT>
<Script language = JavaScript event = "Click (characterid, button, shift, x, y )"
For = agentcontrol>
<! --
// Insert Click Event code here
-->
</SCRIPT>
<Script language = JavaScript event = "dblclick (characterid, button, shift, x, y )"
For = agentcontrol>
<! --
// Purpose: Stop and hide all characters on double-click
Merlin. stopall ();
If (! Merlin. hasotherclients)
{
If (Merlin. Visible ){
Agentintro ()
// Hidereq = Merlin. Hide ();
}
Else {
Agentcontrol. characters. character. Unload (merlinid );
}
}
// -->
</SCRIPT>
<Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
<Meta content = "Microsoft FrontPage 6.0" name = generator> <Body style = "background-color: # ffffff" bgcolor = # ffffff>
</Body>