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

  1. !!Script 
  2. // Copyright ⌐ 1997-1998 - Modelworks Software
  3. // @Modified build 497 cm20010225
  4.  
  5. /**
  6. @Tool: chooseBookmark~lets you choose a bookmark to go to. 
  7. The list of bookmarks displayed in this dialog are stored in the 
  8. bookmark map file. 
  9. @Image: Choose Bookmark Dialog@chooseBookmark_Dialog.gif
  10. @EndTool: 
  11. @Summary: chooseBookmark~lets you choose a bookmark to go to 
  12. */
  13.  
  14. function DoCommand()
  15.     var bookmarkMap = getMapFile("Bookmarks");
  16.     
  17.     var list = newList();
  18.     var position = bookmarkMap.getHeadPosition();
  19.     while (position && position.valid)
  20.     {
  21.         var next = bookmarkMap.getNext(position);
  22.         if (next.value)
  23.         {
  24.             if (next.value.valid())
  25.             {
  26.                 list.addTail(next);
  27.             }
  28.             else
  29.             {
  30.                 bookmarkMap.remove(next.value.hashKey);
  31.             }
  32.         }
  33.         else
  34.         {
  35.             bookmarkMap.removeAll(); // Error
  36.         }
  37.     }
  38.     
  39.     if (list.count == 0)
  40.     {
  41.         alert("No bookmarks to choose from");
  42.         return;
  43.     }
  44.     
  45.     list.sort();
  46.  
  47.     var result = chooseFromList("Choose bookmark",
  48.         list, getString, false, false);
  49.     
  50.     if (result)
  51.     { 
  52.         result.value.go();
  53.     }
  54. }
  55.  
  56. // Callback to get the display string for each item in the
  57. // chooseFromList function
  58. function getString(item)
  59. {
  60.     // Assumes is is an association
  61.     var bookmark = item.value;
  62.     if (bookmark)
  63.     {
  64.         return bookmark.path + ":" + (bookmark.startLineIndex+1) + " - " + bookmark.description;
  65.     }
  66.     return "Invalid Bookmark";
  67. }
  68.  
  69. !!/Script
  70.