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

  1. //--------------------------------------------------------------------------
  2. // Object Scripting
  3. // Copyright (c) 1996, 1997 by Borland International, All Rights Reserved
  4. //
  5. // PRJNOTES.SPP: Project Notes. For new projects, creates a notes text file
  6. //   in the project directory and adds it to the project. The notes file
  7. //   will contain any text found in a template file.
  8. //
  9. // USE: Enter any desired template text in prjnotes.dat. Run script and
  10. //   create a new project.
  11. //
  12. // FILES: PRJNOTES.DAT, MISC.SPP
  13. //
  14. // NOTES: All prjnotes.* files must reside in the same directory.
  15. //--------------------------------------------------------------------------
  16. print typeid(module());
  17.  
  18. //
  19. // IDE imports.
  20. //
  21. import IDE;
  22. import scriptEngine;
  23.  
  24. //
  25. // Load support module(s).
  26. //
  27. if (!scriptEngine.IsLoaded("msg")) scriptEngine.Load("msg");
  28. if (!scriptEngine.IsLoaded("misc")) scriptEngine.Load("misc");
  29.  
  30. ModuleDir = GetModuleDir(typeid(module()));  // Directory of this script.
  31.  
  32. //
  33. // Dummy like-named function to cause module load by function invocation.
  34. //
  35. prjnotes()
  36. {
  37. }
  38.  
  39. //
  40. // Adds a prjnotes.txt node.
  41. //
  42. AddNotesNode()
  43. {
  44.   // Instantiate a project node object.
  45.   //
  46.   declare topNode = new ProjectNode();
  47.   declare projNode = new ProjectNode(topNode.Name + ".exe");
  48.  
  49.   // Copy the template file to the project directory as prjnotes.txt.
  50.   //
  51.   declare notesFile = IDE.CurrentDirectory + "\\notes.txt";
  52.   CopyFile(ModuleDir + "\\prjnotes.dat", notesFile, FALSE);
  53.  
  54.   // Add the notes file as a node.
  55.   //
  56.   projNode.Add(notesFile);
  57. }
  58.  
  59. //
  60. // Hook File | New -> Project.
  61. //
  62. on IDE:>FileNew(toolName, fileName)
  63. {
  64.   // Pass to create the new item.
  65.   //
  66.   declare retVal = pass(toolName, fileName);
  67.  
  68.   // Add notes node.
  69.   //
  70.   if (toolName == "Project") {
  71.     AddNotesNode();
  72.   }
  73.  
  74.   // Be sure to return the outcome from down the handler chain.
  75.   //
  76.   return retVal;
  77. }
  78.  
  79.