Working with Requests

The Request object is the only object that is not directly part of the MSAgent control. This object is returned by many methods that operate asynchronously, such as Character.Play and Character.Speak. Since these methods will operate while your application continues to run, you can periodically check to see the progress of the method. You can also pass this object to the Character.Wait method to ensure that your requested action has finished before continuing onto the next one. Table 14.13 lists the properties available for the Request object.

Table 14.13: Request Object Properties

Property Description
Description Contains a text description of the error
Number Contains an error code; if this value is 0, no error occurred
Status Contains the status of the request

The Number property will contain 0 if the request was completed successfully; otherwise, it will contain an error number. The Description property will contain a text message that describes the error. The Status property describes the request’s current state. Table 14.14 lists the status codes and their meanings.

Table 14.14: Request Object Status Codes

Status Description
0 The request was successful.
1 The request failed.
2 The request is pending.
3 The request has been interrupted.
4 The request is in progress.

Two events are also available when using the Request object: RequestStart and RequestComplete. These events will be fired if you create a global Request object to track the status of a specific method. These events will be triggered only in the client object making the request.

WARNING: Upgrade now: In VBScript 1.0, the RequestStart and RequestComplete events will be triggered even if you don’t issue the request using a global reference object. This problem was fixed in VBScript 2.0 (which is included with Visual Studio 98).

© 1998 SYBEX Inc. All rights reserved.