MAXTAG with lifetime tracking of user assigned note tags

If the creator of the note pad requested that XCF track the maximum note tag value ever assigned by the user, use of the MAXTAG keyword for a delete notes request has an additional side effect. After the selected notes are deleted (which includes the case where the set was empty), XCF determines whether the specified MAXTAG value is a new maximum tag value for the note pad. If so, XCF preserves the indicated MAXTAG value as the new maximum note tag value for the note pad.

With a single note delete request, a new tag value can be logically assigned to the note before it is physically deleted. If the newly assigned tag value happened to be a new maximum tag value for the note pad, that value would be preserved as the new maximum tag value. The MAXTAG keyword provides a similar function for a multi-note delete request in the sense that a new tag value can be logically assigned to a collection of deleted notes. However, there are some important differences between the two behaviors.

For a single note delete request, setting the new logical tag value for the note, deleting the note, and preserving its tag value as the maximum tag value for the note pad (as needed) is effectively an atomic operation. If the note is successfully deleted, the new tag value is guaranteed to be preserved as the new maximum tag value for the note pad (if appropriate). For a multi-note delete request, the deletion of each note and the preservation of its tag value as the maximum tag value for the note pad (as needed) is effectively an atomic operation. However, the setting of the new logical tag value for the collection of deleted notes per the MAXTAG specification is performed as a separate operation after the notes have been deleted. If the notes are deleted, there is no guarantee that the indicated MAXTAG value will be preserved as the new maximum tag value for the note pad. As the result of a failure, the specified MAXTAG value might not be preserved in the note pad.

CAUTION:
If your application cannot tolerate a failure to record the specified MAXTAG value as the new maximum tag value when deleting a collection of notes, consider using single note delete requests to delete the notes one at a time. Preservation of the maximum note tag is guaranteed to be atomic when deleting a single note. For example, you might issue a multi-note read request to determine the set of notes to be deleted and then use single note delete requests to delete all but one note in the set. When deleting the last note, set the a new tag value equal to the desired MAXTAG value.