home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Misc / dumpGlobals.script < prev    next >
Encoding:
Text File  |  2001-06-19  |  1.6 KB  |  77 lines

  1. !!script
  2. // Copyright ⌐ 1997-1999 - Modelworks Software
  3. // @Modified build 260 cm19990128 - changed output to list the object type 
  4.  
  5. /**
  6. @Tool: dumpGlobals~lists all the global keys and values.
  7. @EndTool: 
  8. @Summary: dumpGlobals~lists all the global keys and values
  9. */
  10.  
  11. var gOutput = getOutput();
  12.  
  13. function DoCommand()
  14. {
  15.     gOutput.clear();
  16.     var globalsMap = getGlobalMap();
  17.     if (globalsMap)
  18.     {
  19.         gOutput.writeLine("Dumping Global Data");
  20.         DumpStringMapFile(globalsMap);
  21.         gOutput.writeLine("Finished Global Data");
  22.     }
  23. }
  24.  
  25. function DumpStringMapFile(map)
  26. {   
  27.     var list = newList();
  28.     if (map)
  29.     {
  30.         var position = map.getHeadPosition();
  31.         while (position && position.valid)
  32.         {
  33.             list.addTail(map.getNext(position));
  34.         }
  35.     }
  36.     if (list.count)
  37.     {
  38.         list.sort(compareItems);
  39.         var position = list.getHeadPosition();
  40.         while (position && position.valid)
  41.         {
  42.             var association = list.getNext(position);
  43.             if (association.value)
  44.             {
  45.                 if (typeof(association.value) != "object")
  46.                 {
  47.                     gOutput.writeLine("Key \"" + association.key + "\" has a value of \"" + association.value + "\"");
  48.                 }
  49.                 else
  50.                 {
  51.                     gOutput.writeLine("Key \"" + association.key + "\" is a " + association.value.type + " object");
  52.                 }
  53.             }
  54.             else
  55.             {
  56.                 gOutput.writeLine("Key \"" + association.key + "\" has a value of null");
  57.             }
  58.         }
  59.     }
  60. }
  61.  
  62. function compareItems(itemA, itemB)
  63. {
  64.     // Assumes itemA and itemB are Association objects
  65.     var itemApath = itemA.key.toLowerCase();
  66.     var itemBpath = itemB.key.toLowerCase();
  67.     if (itemApath < itemBpath)
  68.     return -1;
  69.     if (itemApath == itemBpath)
  70.     return 0;
  71.     
  72.     return 1;
  73. }
  74.  
  75. !!/script
  76.  
  77.