home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDON.PAK / SCRIPT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.9 KB  |  90 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.   script.cpp
  4.   Created: 10/28/95
  5.   Copyright (c) 1995, Borland International
  6.   $Revision:   1.18  $
  7.   
  8.   To try this out, make sure and put ssinit.spp and sstest.spp in your
  9.   bc5\script directory. Then, pay attention to the "script" page in the 
  10.   message window. You should see a print of "ssinit.spp" at startup time
  11.   in the message window.
  12.    
  13. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/  
  14. #ifndef __AOEXPCH_H
  15.   #include "aoexpch.h"
  16. #endif
  17. #pragma hdrstop
  18.  
  19. #include <ideaddon\iscript.h>
  20. #include "script.h"
  21.  
  22. //.............................................................................
  23. ScriptTestA::ScriptTestA() { 
  24.   _scriptServer = GET_INTERFACE( IScriptServer ); 
  25.   if ( _scriptServer ) {
  26.     OutStr( "Scheduling script: ssinit.spp" );
  27.     _scriptServer->ScheduleScriptFile( MakePolyString( "ssinit" ) );
  28.     _scriptServer->Release();
  29.   }
  30.   _scriptServer = NULL;
  31. }
  32. //.............................................................................
  33. ScriptTestA::~ScriptTestA() {
  34.   UnInit();
  35. }
  36. //.............................................................................
  37. BOOL ScriptTestA::Init() {
  38.   OutStr( "ScriptTestA::Init()" );
  39.   if ( !_scriptServer ) {
  40.     _scriptServer = GET_INTERFACE( IScriptServer );
  41.   }
  42.   return TRUE;
  43. }
  44. //.............................................................................
  45. void ScriptTestA::UnInit() {
  46.   OutStr( "OptionSetTestA::UnInit()" );
  47.   if ( _scriptServer ) {
  48.     _scriptServer->Release();
  49.     _scriptServer = NULL;
  50.   }
  51. }  
  52. //.............................................................................
  53. const char * ScriptTestA::GetName() {
  54.   return "ScriptServer Test A";
  55. }
  56. //.............................................................................
  57. const char * ScriptTestA::GetTestDescription( int testNum ) {
  58.   switch ( testNum ) {
  59.     case 1: 
  60.       return "Runs script: sstest.spp.";
  61.     case 2:
  62.       return "Runs script command: SSAddOnTest(); (function in sstest.spp)";
  63.   }
  64.   return "This test not implemented.";
  65. }  
  66. //.............................................................................
  67. void ScriptTestA::DoTest( int testNum ) {
  68.   if ( !_scriptServer ) {
  69.     OutStr( "Script Server not initialized!" );
  70.     return;
  71.   }
  72.   switch ( testNum ) {
  73.     case 1: {
  74.       _scriptServer->RunScriptFile( MakePolyString( "sstest" ) );
  75.       break;
  76.     }
  77.     case 2: {
  78.       IPolyString * retstr = CreatePolyString();
  79.       int res = _scriptServer->RunScriptCommand( 
  80.                     MakePolyString( "return SSAddOnTest();" ), retstr );
  81.       OutStr( FormatStr( "Command result: %d \"%s\"", res, retstr->GetCstr() ) );
  82.       retstr->Release();
  83.       break;
  84.     }
  85.     default: {
  86.       OutStr( FormatStr( "Test #%d Not Implemented!", testNum ) );
  87.     }
  88.   }
  89. }
  90.