home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / DUMPSTRINGMAPFILE.SCRIPT < prev    next >
Encoding:
Text File  |  2002-10-26  |  1.6 KB  |  70 lines

  1. !!script
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3.  
  4. /**
  5. @Tool: dumpStringMapFile~lists all the keys and values in a MapFile.
  6. @EndTool: 
  7. @Summary: dumpStringMapFile~lists all the keys and values in a MapFile
  8. */
  9.  
  10. var gOutput = getOutput();
  11.  
  12. function DoCommand()
  13. {
  14.   gOutput.clear();
  15.   var mapFilePath = chooseFile("Choose a MapFile to dump", "MapFile (*.map)", "*.map");
  16.   if (mapFilePath)
  17.   {
  18.     var mapFile = getMapFile(mapFilePath.title, false);
  19.     if (mapFile == null)
  20.     {
  21.        mapFile = getMapFile(mapFilePath.path, false);
  22.     }
  23.     if (mapFile)
  24.     {
  25.       DumpStringMapFile(mapFile);
  26.     }
  27.   }
  28. }
  29.  
  30. function DumpStringMapFile(mapFile)
  31. {   
  32.   gOutput.writeLine("Dumping MapFile " + mapFile.fileName);
  33.   var list = newList();
  34.   if (mapFile)
  35.   {
  36.     var position = mapFile.getHeadPosition();
  37.     while (position && position.valid)
  38.     {
  39.       list.addTail(mapFile.getNext(position));
  40.     }
  41.   }
  42.   if (list.count)
  43.   {
  44.     list.sort(compareItems);
  45.     var position = list.getHeadPosition();
  46.     while (position && position.valid)
  47.     {
  48.       var association = list.getNext(position);
  49.       gOutput.writeLine("Key \"" + association.key + "\" has a value of \"" + association.value + "\"");
  50.     }
  51.   }
  52.   gOutput.writeLine("Finished dumping MapFile " + mapFile.fileName);
  53. }
  54.  
  55. function compareItems(itemA, itemB)
  56. {
  57.   // Assumes itemA and itemB are Association objects
  58.   var itemApath = itemA.key.toLowerCase();
  59.   var itemBpath = itemB.key.toLowerCase();
  60.   if (itemApath < itemBpath)
  61.     return -1;
  62.   if (itemApath == itemBpath)
  63.     return 0;
  64.     
  65.   return 1;
  66. }
  67.  
  68. !!/script
  69.  
  70.