C++ Pets Callback Sample

This is a slightly more complex version of Pets in which the Prolog program has a prompt/2 predicate used to get information from the user. In the example, it is used to ask the user for the sound the pet makes.

prompt/2 is implemented as an extended predicate in the C++ class derived from CLogicServer, illustrating the technique of having extended predicates associated with instances of classes derived from the Logic Server.

This is a trivial console example, where there is no real point in having multiple instances of the prompt/2 predicate, but the technique is important for GUI applications where, for example, different instances of the Logic Server might be associated with different windows on the screen.

Building the Sample

  1. Compile and link pets.pro into pets.xpl.
  2. Under Windows, open the Microsoft Visual C++ Project pets_callback.dsw and build pets_callback.exe.
  3. Under Unix, run the appropriate makefile under Linux (makefile.lnx) or Solaris (makefile.sol) to build pets

Running the Sample

  1. Run pets_callback(.exe).
  2. Enter a sound like 'woof', 'quack' or 'meow'.

Copyright ©1987-2004 Amzi! inc. All Rights Reserved. Amzi! is a registered trademark and Logic Server and e-Prolog are trademarks of Amzi! inc.