Announcement

Collapse
No announcement yet.

MSAgent and oRequest.Status

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MSAgent and oRequest.Status

    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.

    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:
    Code:
    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

  • #2
    How does oRequest.status get refreshed?

    Comment


    • #3
      Not Sure

      I'm not exactly sure. I think MS Agent automatically sets the status while speaking or animating. In the past, all I had to do was get the request from the command and then check with a loop of some kind.

      I do know that when I put a message before the loop it shows a status of two (2) which is correct. If I put two messages back to back:
      Code:
        msgbox format$(oRequest.Status)
        msgbox format$(oRequest.Status)
      The first shows two (2). Now I wait until the speech is done and press OK. The second one shows zero (0).

      It's as if the do...loop does not check events. It may be a bug with PowerBasic 9.0.

      I'm going to try using a goto, for...next, and other things that come to mind and see if it makes a difference.

      Randy

      Comment


      • #4
        Do you have an example in another language? Also, is it possible that the processing up to the point where the status is changed is all done during the SLEEP 100?

        Comment


        • #5
          I Checked

          Hi again Chris,

          I tried it without the sleep command and no such luck. Basically, it shouldn't make a difference since it would sleep about a tenth of a second, hit the "Loop Until" and bail out after it sees the status is zero.

          I've tried other ways to loop and I even thought that maybe with a Graphic Inkey$ I could get the keyboard to trigger an event check but no such luck.

          What I've done for now is use Sleep 500 * ParseCount(CharCmd$, $SPC) and avoid the loop completely. It's not perfect and really is just a kludge. I don't care for kludges. It goes against the grain of being a perfectionist. :laugh:

          As far as another language, I used AutoIT for this previously and it looks almost identical.

          Code:
          $oResult = $AgentCharsEx.Speech($CharCmd)
          
          While $oResult.Status > 0
             Sleep 100
          Wend
          I've tried While/Wend, For/Next, and Goto as well and it made no difference.

          Open for more suggestions... :coffee3:

          Randy

          Comment


          • #6
            Randy, I don't know what the context is but maybe you need to allow messages to be processed while you SLEEP, try:

            Code:
            do 
                dialog doevents 2 
            loop until $oResult.Status > 0
            Or you could post more code and get more interest!

            Comment

            Working...
            X