home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
- /**
- @Tool: printPackage() prints all the files in a package.
- @EndTool:
- @Summary: printPackage prints all the files in a package
- */
-
- function DoUpdate(cmdUI)
- {
- cmdUI.enable(getCurrentProject() != null);
- return true;
- }
-
- function DoCommand()
- {
- var project = getCurrentProject();
-
- if (project)
- {
- var packageList = project.getPackageList();
- if (packageList && packageList.count >= 1)
- {
- if (packageList.count > 1)
- {
- var packageToPrint =
- chooseFromList("Choose package to print",
- packageList, getPackageString, false);
-
- if (packageToPrint)
- {
- PrintFiles(packageToPrint);
- }
- }
- else if (packageList.count == 1)
- {
- PrintFiles(packageList.removeHead());
- }
- }
- else
- {
- alert("You must add a package before printing");
- }
- }
- else
- {
- alert("A project must be open before you can print a package");
- }
- }
-
- function PrintFiles(fromPackage)
- {
- // Get list of files included in the package
- var sourceFileList = fromPackage.getBuildFileList(false);
- if (sourceFileList)
- {
- var position = sourceFileList.getHeadPosition();
- while (position.valid)
- {
- var file = sourceFileList.getNext(position);
- if (file)
- {
- var editor = openEditor(file.path);
- if (editor)
- {
- editor.print();
- }
- }
- }
- }
- }
-
- function getPackageString(item)
- {
- // assumes item is a package
- if (item.name.length > 0)
- {
- return item.name + " - " + item.sourcePath ;
- }
- return "<untitled> - " + item.sourcePath;
- }
-
- !!/Script
-