home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- // Object Scripting
- // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
- //
- // AUTO.SPP: Automation. Demonstrates the IDE as an OLE automation
- // controller and server.
- //
- // USE: Invoke calc(), word(), excel(), or bcwIDE(). Before executing
- // calc(), you must build the OCF example autocalc.ide. Before executing
- // word(), you must install Word for Windows. Before executing excel(),
- // you must install Excel for Windows. Before executing bcwIDE(), set
- // the constant TEST_PROJECT to a fully-qualified IDE file on your
- // system.
- //--------------------------------------------------------------------------
- print typeid(module());
-
- //
- // Drive Autocalc as an automation server.
- //
-
- CalcObj;
-
- calc()
- {
- CalcObj = new OleObject("OCCalc.Application");
- print CalcObj;
-
- CalcObj.Button("42");
- }
-
- //
- // Drive Word as an automation server.
- //
-
- WordObj;
-
- word()
- {
- WordObj = new OleObject("Word.Basic");
- print WordObj;
-
- WordObj.FileNew();
- WordObj.Insert("Send me no more reports, let them fly, all!");
- }
-
- //
- // Drive Excel as an automation server.
- //
-
- ExcelObj;
-
- excel()
- {
- ExcelObj = new OleObject("Excel.Application");
- ExcelObj.Application.Visible = -1;
- ExcelObj.Workbooks.Add();
- ExcelObj.ActiveSheet.Cells(1, 1).Value =
- "Til Burnham Wood remove to Dunsinane...";
- ExcelObj.ActiveSheet.Cells(2, 1).Value =
- "...I cannot taint with fear.";
- }
-
- //
- // Automate the IDE.
- //
-
- IdeObj;
- #define TEST_PROJECT "C:\\BC5\\EXAMPLES\\WINDOWS\\WHELLO\\WHELLO.IDE"
-
- import "kernel32.dll" {
- void Sleep (long);
- }
-
- bcwIDE()
- {
- IdeObj = new OleObject("BorlandIDE.Application");
- print IdeObj;
-
- // Give the IDE a chance to load fully.
- //
- Sleep(5000);
- IdeObj.Message("Thanks!");
-
- declare rslt;
-
- rslt = IdeObj.ProjectOpenProject(TEST_PROJECT);
- if (rslt == FALSE) {
- IdeObj.Message("Failed to open test project.");
- }
- else {
- IdeObj.Message("Opened test project okay.");
- }
-
- rslt = IdeObj.ProjectMakeAll(TRUE);
- if (rslt == FALSE) {
- IdeObj.Message("Failed to start make of test project.");
- }
- else {
- IdeObj.Message("Started make of test project okay.");
- }
- }
-
-