home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 497 cm20010225
-
- /**
- @Tool: chooseBookmark~lets you choose a bookmark to go to.
- The list of bookmarks displayed in this dialog are stored in the
- bookmark map file.
- @Image: Choose Bookmark Dialog@chooseBookmark_Dialog.gif
- @EndTool:
- @Summary: chooseBookmark~lets you choose a bookmark to go to
- */
-
- function DoCommand()
- {
- var bookmarkMap = getMapFile("Bookmarks");
-
- var list = newList();
- var position = bookmarkMap.getHeadPosition();
- while (position && position.valid)
- {
- var next = bookmarkMap.getNext(position);
- if (next.value)
- {
- if (next.value.valid())
- {
- list.addTail(next);
- }
- else
- {
- bookmarkMap.remove(next.value.hashKey);
- }
- }
- else
- {
- bookmarkMap.removeAll(); // Error
- }
- }
-
- if (list.count == 0)
- {
- alert("No bookmarks to choose from");
- return;
- }
-
- list.sort();
-
- var result = chooseFromList("Choose bookmark",
- list, getString, false, false);
-
- if (result)
- {
- result.value.go();
- }
- }
-
- // Callback to get the display string for each item in the
- // chooseFromList function
- function getString(item)
- {
- // Assumes is is an association
- var bookmark = item.value;
- if (bookmark)
- {
- return bookmark.path + ":" + (bookmark.startLineIndex+1) + " - " + bookmark.description;
- }
- return "Invalid Bookmark";
- }
-
- !!/Script
-