home *** CD-ROM | disk | FTP | other *** search
- !!script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
- /**
- @Tool: dumpStringMapFile~lists all the keys and values in a MapFile.
- @EndTool:
- @Summary: dumpStringMapFile~lists all the keys and values in a MapFile
- */
-
- var gOutput = getOutput();
-
- function DoCommand()
- {
- gOutput.clear();
- var mapFilePath = chooseFile("Choose a MapFile to dump", "MapFile (*.map)", "*.map");
- if (mapFilePath)
- {
- var mapFile = getMapFile(mapFilePath.title, false);
- if (mapFile == null)
- {
- mapFile = getMapFile(mapFilePath.path, false);
- }
- if (mapFile)
- {
- DumpStringMapFile(mapFile);
- }
- }
- }
-
- function DumpStringMapFile(mapFile)
- {
- gOutput.writeLine("Dumping MapFile " + mapFile.fileName);
- var list = newList();
- if (mapFile)
- {
- var position = mapFile.getHeadPosition();
- while (position && position.valid)
- {
- list.addTail(mapFile.getNext(position));
- }
- }
- if (list.count)
- {
- list.sort(compareItems);
- var position = list.getHeadPosition();
- while (position && position.valid)
- {
- var association = list.getNext(position);
- gOutput.writeLine("Key \"" + association.key + "\" has a value of \"" + association.value + "\"");
- }
- }
- gOutput.writeLine("Finished dumping MapFile " + mapFile.fileName);
- }
-
- function compareItems(itemA, itemB)
- {
- // Assumes itemA and itemB are Association objects
- var itemApath = itemA.key.toLowerCase();
- var itemBpath = itemB.key.toLowerCase();
- if (itemApath < itemBpath)
- return -1;
- if (itemApath == itemBpath)
- return 0;
-
- return 1;
- }
-
- !!/script
-
-