ToolBook Scripts for MSAgents

            

On You Book Script:

to handle enterApplication
  send reader
  send setup_agent
  forward
end

to handle setup_agent
  open viewer "agent control"
  send _Agent_Init to agent "Agent Control" of page "Agent Control"
end

Create a NonViewed Page named 'Agent Control' with the following object:

Create an Active X Object following Tom's Directions and code the following to the object:

(This loads both Merlin and Judd)
--Code modified from original code by Slade Mitchell
--Asymetrix Learning Systems, INc.

--to get bookPath
--  temp=name of this book
--  while (last char of temp is not "\")
--    clear last char of temp
--    end
--  return temp
--end


to handle _Agent_Init
  system s_AgentSystem
  s_AgentSystem = self
  errMsg = null
  syssuspend=false
  
--Load Judd Character

  JuddFile = Asym_WindowsDirectory() & "msagent\chars\judd.acs"
  --JuddFile = bookpath() & "judd.ace"
  fileToTest = juddFile
  loadsuccess = false
  while (fileToTest <> null) and (loadsuccess = false)
  pop fileToTest into thisFile
  characterFile = thisFile
    if ASYM_IsFile(characterFile) then
    get extLoad("judd", characterFile) of extCharacters of s_AgentSystem
         loadsuccess = true
    end if
  end while
  
--End of Load Judd Character

--Load Merlin Character

    refMerlin = extCharacter("Merlin") of extCharacters() of s_AgentSystem
    syssuspend=true
    
    MerlinFile = Asym_WindowsDirectory() & "msagent\chars\Merlin.acs"
  --MerlinFile = bookpath() & "Merlin.ace"
  fileToTest = MerlinFile
  loadsuccess = false
  while (fileToTest <> null) and (loadsuccess = false)
  pop fileToTest into thisFile
  characterFile = thisFile
    if ASYM_IsFile(characterFile) then
    get extLoad("Merlin", characterFile) of extCharacters of s_AgentSystem
         loadsuccess = true
    end if
  end while
  
--End of Load Merlin Character

    refjudd = extCharacter("judd") of extCharacters() of s_AgentSystem
    syssuspend=true
end

Now you may script any object in the book:

(I use buttons so that the user has options to play a Character)

Example (First Page of Learning Styles):

to handle buttonClick

--You need the following in each script
   system s_AgentSystem
   syssuspend = false
   refJudd = extCharacter("Judd") of extCharacters() of s_AgentSystem
   
--This is up to you: the actual dialog
   get extMoveTo(500,150) of refJudd
   get extShow() of refJudd
   get extPlay("acknowledge") of refJudd
   get extSpeak("Hello, my name is Judd. I am the special MicroSoft Agent created by Jo Doell.") of refJudd
   get extPlay("advertise") of refJudd
   get extSpeak("I represent the author of this software: John Taylor \pau=300\ of Hillsborough Community College \pau=300\ in Tampa, Florida.") of refJudd
   get extPlay("getAttention") of refJudd
   get extSpeak("I am here to tell you the story of Learning Styles!") of refJudd
   get extPlay("explain") of refJudd
   get extMoveTo(450,300) of refJudd
   get extPlay("domagic2") of refJudd
   get extSpeak("Who did you think would show up, Tiger Woods? I am ready for a good round of golf. Maybe you would rather play golf today?   But my master,\pau=1000\ a real slave driver,  wants me to acquaint yourself with Kolbe's Learning Style Inventory that is published in Chapter One of Dave Ellis's Becoming a Master Student") of refJudd
   get extPlay("attention") of refJudd
   get extSpeak("At any time, if I annoy you you may right click on me and select hide. I will not be offended. I just exit the screen through my secret door!") of refJudd
   get extHide() of refJudd
   
--you must reset syssuspend
   syssuspend = true
 end

For different characters replace Judd in the script with the Character Name

Multiple character dialogs requires tricks which are only documented
in M.E. Yoder's "Using MS Agent in Toolbook"

View Sample Chapter 3 (pdf file)