home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / PRINTPACKAGE.SCRIPT < prev    next >
Encoding:
Text File  |  1998-05-14  |  1.7 KB  |  85 lines

  1. !!Script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: printPackage() prints all the files in a package.
  6. @EndTool: 
  7. @Summary: printPackage prints all the files in a package 
  8. */
  9.  
  10. function DoUpdate(cmdUI) 
  11. {
  12.   cmdUI.enable(getCurrentProject() != null);
  13.   return true;
  14. }
  15.  
  16. function DoCommand()
  17. {
  18.   var project = getCurrentProject();
  19.   
  20.   if (project)
  21.   {
  22.     var packageList = project.getPackageList();
  23.     if (packageList && packageList.count >= 1)
  24.     {
  25.       if (packageList.count > 1)
  26.       {
  27.         var packageToPrint = 
  28.           chooseFromList("Choose package to print",
  29.           packageList, getPackageString, false);
  30.         
  31.         if (packageToPrint)
  32.         {
  33.           PrintFiles(packageToPrint);
  34.         }
  35.       }
  36.       else if (packageList.count == 1)
  37.       {
  38.         PrintFiles(packageList.removeHead());
  39.       }
  40.     }
  41.     else
  42.     {
  43.       alert("You must add a package before printing");
  44.     }
  45.   }
  46.   else
  47.   {
  48.     alert("A project must be open before you can print a package");
  49.   }
  50. }
  51.  
  52. function PrintFiles(fromPackage)
  53. {
  54.   // Get list of files included in the package
  55.   var sourceFileList = fromPackage.getBuildFileList(false);
  56.   if (sourceFileList)
  57.   {
  58.     var position = sourceFileList.getHeadPosition();
  59.     while (position.valid)
  60.     {
  61.       var file = sourceFileList.getNext(position);
  62.       if (file)
  63.       {
  64.         var editor = openEditor(file.path);
  65.         if (editor)
  66.         {
  67.           editor.print();
  68.         }
  69.       }
  70.     }
  71.   }
  72. }
  73.  
  74. function getPackageString(item)
  75. {
  76.   // assumes item is a package
  77.   if (item.name.length > 0)
  78.   {
  79.     return item.name + " - " + item.sourcePath ;
  80.   }
  81.   return "<untitled> - " + item.sourcePath;
  82. }
  83.  
  84. !!/Script
  85.