home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / SCRPTEXM.PAK / SOUND.SPP < prev    next >
Encoding:
Text File  |  1997-05-06  |  2.7 KB  |  111 lines

  1. //--------------------------------------------------------------------------
  2. // Object Scripting
  3. // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
  4. //
  5. // SOUND.SPP: Sound Enabler. Plays WAV files on specified IDE events, such
  6. //   as Build Failure.
  7. //
  8. // USE: Set values in sound.cfg. Run script.
  9. //
  10. // FILES: SOUND.CFG, FILE.SPP, MISC.SPP
  11. //
  12. // NOTES: All sound.* files must reside in the same directory.
  13. //--------------------------------------------------------------------------
  14. print typeid(module());
  15.  
  16. //
  17. // IDE imports.
  18. //
  19. import IDE;
  20. import editor;
  21. import scriptEngine;
  22. import debugger;
  23.  
  24. //
  25. // Load support module(s).
  26. //
  27. if (!scriptEngine.IsLoaded("file")) scriptEngine.Load("file");
  28. if (!scriptEngine.IsLoaded("misc")) scriptEngine.Load("misc");
  29.  
  30. //
  31. // Configuration values.
  32. //
  33. BuildCompleteSuccessWAV;
  34. BuildCompleteFailureWAV;
  35. MakeCompleteSuccessWAV;
  36. MakeCompleteFailureWAV;
  37. DebugeeStoppedWAV;
  38. ExitingWAV;
  39. StartedWAV;
  40.  
  41. CFGFile = GetModuleDir(typeid(module())) + "\\sound.cfg";  // The config file.
  42.  
  43. sound()
  44. {
  45.   //
  46.   // Load configuration values.
  47.   //
  48.   declare File = new TConfigFile(CFGFile);
  49.  
  50.   BuildCompleteSuccessWAV = File.GetValue("BuildCompleteSuccess", "None");
  51.   BuildCompleteFailureWAV = File.GetValue("BuildCompleteFailure", "None");
  52.   MakeCompleteSuccessWAV = File.GetValue("MakeCompleteSuccess", "None");
  53.   MakeCompleteFailureWAV = File.GetValue("MakeCompleteFailure", "None");
  54.   DebugeeStoppedWAV = File.GetValue("DebugeeStopped", "None");
  55.   ExitingWAV = File.GetValue("Exiting", "None");
  56.   StartedWAV = File.GetValue("Started", "None");
  57.  
  58.   File.Close();
  59. }
  60.  
  61. //
  62. // Handlers to tie sounds to IDE events.
  63. //
  64. on debugger:>DebugeeStopped()
  65. {
  66.   if (DebugeeStoppedWAV != "None") {
  67.     declare wav = new TWAVFile(DebugeeStoppedWAV);
  68.     wav.Play();
  69.   }
  70.   pass();
  71. }
  72.  
  73. on IDE:>BuildComplete(status, inputPath, outputPath)
  74. {
  75.   if (BuildCompleteSuccessWAV != "None" &&
  76.       BuildCompleteFailureWAV != "None") {
  77.     declare file = status ? BuildCompleteSuccessWAV : BuildCompleteFailureWAV;
  78.     declare wav = new TWAVFile(file);
  79.     wav.Play();
  80.   }
  81.   pass(status, inputPath, outputPath);
  82. }
  83.  
  84. on IDE:>MakeComplete(status, inputPath, outputPath)
  85. {
  86.   if (MakeCompleteSuccessWAV != "None" && MakeCompleteFailureWAV != "None") {
  87.     declare file = status ? MakeCompleteSuccessWAV : MakeCompleteFailureWAV;
  88.     declare wav = new TWAVFile(file);
  89.     wav.Play();
  90.   }
  91.   pass(status, inputPath, outputPath);
  92. }
  93.  
  94. on IDE:>Exiting()
  95. {
  96.   if (ExitingWAV != "None") {
  97.     declare wav = new TWAVFile(ExitingWAV);
  98.     wav.Play();
  99.   }
  100.   pass();
  101. }
  102.  
  103. on IDE:>Started(firstTime)
  104. {
  105.   if (StartedWAV != "None") {
  106.     declare wav = new TWAVFile(StartedWAV);
  107.     wav.Play();
  108.   }
  109.   pass(firstTime);
  110. }
  111.