ContentsIndexPreviousNext

Code Examples

Format 9:

The following program uses the Microsoft Agent Control (ActiveX) to create a "genie" character and then directs it to speak "Hello World". It does not have a visible initial window or a user interface that allows keyboard or mouse input.

identification division.
program-id.  no-ui.
environment division.
special-names.
copy "msagent.def".
                  .
data division.
working-storage section.

77  genie1-handle          usage handle of Agent.
77  request-handle         usage handle of IAgentCtlRequest.
77  request-status         pic 9.

procedure division.
Main-Logic.

    display initial window visible = 0.

    display Agent of AgentObjects handle in genie1-handle.

    modify genie1-handle Characters::Load("Genie1", "genie.acs").

    use genie1-handle Characters::Item("Genie1")

        modify ^LanguageID 1033
               ^Show()
               ^Speak "Hello World" giving request-handle

        perform until request-status = 1
            ACCEPT EVENT BEFORE TIME 1000
            inquire request-handle status in request-status
        end-perform

        destroy request-handle

        modify ^Hide()

    end-use.

    destroy genie1-handle.

    stop run.