• Welcome to Theos PowerBasic Museum 2017.

MSAgent and oRequest.Status

Started by Randal Lanning, January 31, 2009, 05:12:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Randal Lanning

This one is a little strange and I apologize if I seem a little dense in this matter, it's just that I've read the manual, checked every forum and even went to some old code that I wrote in another computer language. Jose is considered an expert in COM so I figured his forum would be the best option for me.

I'm working on a personal home automation system and I've got it speaking, animating, reading the news and weather, turning on the lights in the house, and having a general conversation with me. The problem is that when it is reading the news, and let's say there are ten articles it runs through all the text through the last article while it's still speaking on the first.

So, I've tried several things and what I'm trying now seems correct and is in other languages but doesn't seem to work in PB. It looks like this:

oRequest = AgentCharsEx.Speak(CharCmd$)
         
do while oRequest.status > 0
  sleep 100
loop


I've put a msgbox statement before the loop and see that the status is indeed a two (2) which is what I expect while it is active. But it never seems to change once the loop starts. Getting it to wait until it is finished speaking before getting the next article is where my problem lies. If anyone has any ideas let me know please. This is my last major hurdle.

I'm using PB9.0 for Windows, running Vista Ultimate.

Thanks,

Randy

José Roca

 
Maybe you can try the RequestComplete event.


' ########################################################################################
' Class CAgentEvents
' Interface name = _AgentEvents
' IID = {F5BE8BD4-7DE6-11D0-91FE-00C04FD701A5}
' IAgentCtl event interface
' Attributes = 4096 [&H1000] [Dispatchable]
' ########################################################################################

CLASS CAgentEvents GUID$("{9DB92892-A8B6-4CBB-A5CF-6971C0CB3D43}") AS EVENT

INTERFACE AgentEventsImpl GUID$("{F5BE8BD4-7DE6-11D0-91FE-00C04FD701A5}") AS EVENT

  INHERIT IDispatch

   ' =====================================================================================
   METHOD ActivateInput <1> ( _
     BYVAL CharacterID AS STRING _                      ' CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD DeactivateInput <3> ( _
     BYVAL CharacterID AS STRING _                      ' CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Click <2> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL iButton AS INTEGER _                         ' [in] Button VT_I2 <Integer>
   , BYVAL iShift AS INTEGER _                          ' [in] Shift VT_I2 <Integer>
   , BYVAL x AS INTEGER _                               ' [in] x VT_I2 <Integer>
   , BYVAL y AS INTEGER _                               ' [in] y VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD DblClick <4> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL iButton AS INTEGER _                         ' [in] Button VT_I2 <Integer>
   , BYVAL iShift AS INTEGER _                          ' [in] Shift VT_I2 <Integer>
   , BYVAL x AS INTEGER _                               ' [in] x VT_I2 <Integer>
   , BYVAL y AS INTEGER _                               ' [in] y VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD DragStart <5> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL iButton AS INTEGER _                         ' [in] Button VT_I2 <Integer>
   , BYVAL iShift AS INTEGER _                          ' [in] Shift VT_I2 <Integer>
   , BYVAL x AS INTEGER _                               ' [in] x VT_I2 <Integer>
   , BYVAL y AS INTEGER _                               ' [in] y VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD DragComplete <6> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL iButton AS INTEGER _                         ' [in] Button VT_I2 <Integer>
   , BYVAL iShift AS INTEGER _                          ' [in] Shift VT_I2 <Integer>
   , BYVAL x AS INTEGER _                               ' [in] x VT_I2 <Integer>
   , BYVAL y AS INTEGER _                               ' [in] y VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Show <15> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL Cause AS INTEGER _                           ' [in] Cause VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Hide <7> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL Cause AS INTEGER _                           ' [in] Cause VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD RequestStart <9> ( _
     BYVAL Request AS IDispatch _                       ' [in] *Request VT_DISPATCH <IDispatch>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD RequestComplete <11> ( _
     BYVAL Request AS IDispatch _                       ' [in] *Request VT_DISPATCH <IDispatch>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Restart <21>

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Shutdown <12>

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Bookmark <16> ( _
     BYVAL BookmarkID AS LONG _                         ' [in] BookmarkID VT_I4 <Long>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Command <17> ( _
     BYVAL UserInput AS IDispatch _                     ' [in] *UserInput VT_DISPATCH <IDispatch>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD IdleStart <19> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD IdleComplete <20> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Move <22> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL x AS INTEGER _                               ' [in] x VT_I2 <Integer>
   , BYVAL y AS INTEGER _                               ' [in] y VT_I2 <Integer>
   , BYVAL Cause AS INTEGER _                           ' [in] Cause VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD Size <23> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL iWidth AS INTEGER _                          ' [in] Width VT_I2 <Integer>
   , BYVAL iHeight AS INTEGER _                         ' [in] Height VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD BalloonShow <24> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD BalloonHide <25> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD HelpComplete <26> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL bstrName AS STRING _                         ' [in] Name VT_BSTR
   , BYVAL Cause AS INTEGER _                           ' [in] Cause VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD ListenStart <27> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD ListenComplete <28> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL Cause AS INTEGER _                           ' [in] Cause VT_I2 <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD DefaultCharacterChange <30> ( _
     BYVAL bstrGUID AS STRING _                         ' GUID VT_BSTR
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD AgentPropertyChange <31>

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

   ' =====================================================================================
   METHOD ActiveClientChange <32> ( _
     BYVAL CharacterID AS STRING _                      ' [in] CharacterID VT_BSTR
   , BYVAL Active AS INTEGER _                          ' [in] Active VT_BOOL <Integer>
   )                                                    ' VOID

     ' *** Insert your code here ***

   END METHOD
   ' =====================================================================================

END INTERFACE

END CLASS


Make oRequest global and dim a global variable to be used as a flag.


GLOBAL g_RequestCompleted AS LONG



DO
   SLEEP 100
   IF g_RequestCompleted THEN EXIT LOOP
LOOP


and in the RequestComplete method set the flag.


METHOD RequestComplete <11> (BYVAL Request AS IDispatch)
   IF OBJPTR(oRequest) = OBJPTR(Request) THEN
      g_RequestCompleted = %TRUE
   END IF
END METHOD



Randal Lanning

Thanks Jose for the help. It's stuck in the do...loop now for some reason. Could it be that oRequest is dim'd as IAgentCtlRequest?