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

  1. //--------------------------------------------------------------------------
  2. // Object Scripting
  3. // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
  4. //
  5. // AUTO.SPP: Automation. Demonstrates the IDE as an OLE automation
  6. //   controller and server.
  7. //
  8. // USE: Invoke calc(), word(), excel(), or bcwIDE(). Before executing
  9. //   calc(), you must build the OCF example autocalc.ide. Before executing
  10. //   word(), you must install Word for Windows. Before executing excel(),
  11. //   you must install Excel for Windows. Before executing bcwIDE(), set
  12. //   the constant TEST_PROJECT to a fully-qualified IDE file on your
  13. //   system.
  14. //--------------------------------------------------------------------------
  15. print typeid(module());
  16.  
  17. //
  18. // Drive Autocalc as an automation server.
  19. //
  20.  
  21. CalcObj;
  22.  
  23. calc()
  24. {
  25.   CalcObj = new OleObject("OCCalc.Application");
  26.   print CalcObj;
  27.  
  28.   CalcObj.Button("42");
  29. }
  30.  
  31. //
  32. // Drive Word as an automation server.
  33. //
  34.  
  35. WordObj;
  36.  
  37. word()
  38. {
  39.   WordObj = new OleObject("Word.Basic");
  40.   print WordObj;
  41.  
  42.   WordObj.FileNew();
  43.   WordObj.Insert("Send me no more reports, let them fly, all!");
  44. }
  45.  
  46. //
  47. // Drive Excel as an automation server.
  48. //
  49.  
  50. ExcelObj;
  51.  
  52. excel()
  53. {
  54.   ExcelObj = new OleObject("Excel.Application");
  55.   ExcelObj.Application.Visible = -1;
  56.   ExcelObj.Workbooks.Add();
  57.   ExcelObj.ActiveSheet.Cells(1, 1).Value =
  58.     "Til Burnham Wood remove to Dunsinane...";
  59.   ExcelObj.ActiveSheet.Cells(2, 1).Value =
  60.     "...I cannot taint with fear.";
  61. }
  62.  
  63. //
  64. // Automate the IDE.
  65. //
  66.  
  67. IdeObj;
  68. #define TEST_PROJECT "C:\\BC5\\EXAMPLES\\WINDOWS\\WHELLO\\WHELLO.IDE"
  69.  
  70. import "kernel32.dll" {
  71.   void  Sleep  (long);
  72. }
  73.  
  74. bcwIDE()
  75. {
  76.   IdeObj = new OleObject("BorlandIDE.Application");
  77.   print IdeObj;
  78.  
  79.   // Give the IDE a chance to load fully.
  80.   //
  81.   Sleep(5000);
  82.   IdeObj.Message("Thanks!");
  83.  
  84.   declare rslt;
  85.  
  86.   rslt = IdeObj.ProjectOpenProject(TEST_PROJECT);
  87.   if (rslt == FALSE) {
  88.     IdeObj.Message("Failed to open test project.");
  89.   }
  90.   else {
  91.     IdeObj.Message("Opened test project okay.");
  92.   }
  93.  
  94.   rslt = IdeObj.ProjectMakeAll(TRUE);
  95.   if (rslt == FALSE) {
  96.     IdeObj.Message("Failed to start make of test project.");
  97.   }
  98.   else {
  99.     IdeObj.Message("Started make of test project okay.");
  100.   }
  101. }
  102.  
  103.