"Talking to Powerbuilder,"
Volume: 7 Issue: 1, p. 31
Listing 1: Constructor event of the user object
/******************************************* Description : Load the Agent control (Peedy) and make it visible. ********************************************/ // To load the control, use Load Method, passing // it the character animation file name (peedy.acs) // This loads the character's data into Agent // ActiveX control's Characters collection. // Note: by default, downloaded Microsoft Agent // characters are installed in "msagent\chars" // subdirectory under windows(95,98,NT,2000) // directory. ole_agent.object.Characters.Load( "Peedy", & "c:\windows\msagent\chars\peedy.acs") // To make the character appear, use the Show // Method, specifying the character reference // used in Load call in the previous statement. ole_agent.Object.Characters("Peedy").Show Listing 2: Functions of Speak for the user object
/*********************************** Description : Speak out the text Arguments : as_text - Text to speak Returns : None ***********************************/ // To make the character speak, use the Speak // Method, specifying the text to be spoken as // an argument. The spoken text appears in a // word balloon, as in a comic strip, and is also // spoken audibly if a sound card is present. ole_agent.Object.Characters("Peedy").Speak(as_Text) Listing 3: Function of Play for user object
/******************************************* Description : Play a valid animation Arguments : as_act - valid animation action Returns : None ********************************************/ // Once the character is visible, you can play // the character's animation using the Play // Method, specifying the name of the animation. // All the animations for the Microsoft characters // are documented on their Web site. ole_agent.Object.Characters("Peedy").Play(as_Act) Listing 4: Function of AddCommand for the user
/*********************************************** Description : Add commands to the agent's popup Command menu Arguments : as_event - Event to be posted as_text - Text in the agent's popup menu as_voice - Voice grammar for recognition Returns : None ************************************************/ // To add entries on the popup menu of the Agent // control, use Add Method of Commands collection. // First parameter is a unique name you use to // reference the command. Second parameter is the text // that will appear on the popup menu. Third argument // is the voice grammar to be passed to the speech // engine ole_agent.Object.Characters("Peedy").Commands.Add(& as_Event, as_Text, as_Voice ) Listing 5: Command event of the user object
/********************************************* Description : Post the appropriate event on the Window object **********************************************/ window lw_Parent // Get the Window where the agent user object is // located lw_Parent = This.GetParent().GetParent() // To communicate dynamically between objects, I // used the function PostEvent(). I used the // event name to be posted as an identifier for // the command. // Post the required user-defined event on the window // Note: Convert the value of userinput.name to // string. lw_Parent.PostEvent( String(userinput.name) ) Listing 6: Function of Listen for the user object
/*********************************************** Description : Send Scroll Lock Keypressed message using SDK Call, declared locally. Arguments : None Returns : None ***********************************************/ // Press the Scroll lock button keybd_event( 145, 1, 0, 0 )