bool CMarkup::SavePos( MCD_CSTR szPosName = "", int nMap = 0 );
The current position consists of the parent position, the main position and the child position. The SavePos
method saves the position as if it were keeping a named bookmark to remember the full current position. It returns false
if there is no current position.
You can return to a saved position with the RestorePos method. And before using SavePos
you can set the map's hash table size with the SetMapSize method.
Update September 27, 2008: The optional nMap
argument is used for additional maps. You can have any number of maps to save and restore positions of different pieces of indexing information. The default map is 0. For more about using multiple maps, see SetMapSize.
For an example of RestorePos
, after navigating to the position in the document of an element that has certain informational attributes or child elements, call SavePos("info")
and then continue navigating to other areas of the document. If you need to refer back to something at the saved position, call RestorePos("info")
.
You can also store the position with no name, i.e. an empty string, which makes sense if you only have need for one saved position.
The SetDoc and Load methods clear all saved positions. If either the main or child element of the saved position is removed individually or as part of a subdocument, the RestorePos method will fail.
Saved positions are not preserved when the document is in a string or file. This is only for optimization of navigation in memory with a CMarkup object.