Tcl
Tcl
Subtract One MessageSet from Another
See more IMAP Examples
Demonstrates the Chilkat MessageSet.Subtract method, which removes from this set every identifier whose numeric value is also present in another MessageSet. The only argument is the other set. This example starts with ids 1:10, subtracts 2,4,6, and prints what remains.
Background: A common IMAP pattern is "process everything except what I've already handled."
Subtract makes that a single call: remove the already-processed ids from a working set. The comparison is numeric only and this object's HasUids is preserved, so for meaningful results both sets should hold the same id type from the same mailbox. Passing the same object clears the set; passing an empty set changes nothing.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# Demonstrates the MessageSet.Subtract method, which removes from this set every identifier
# that is also present in another MessageSet. The only argument is the other MessageSet.
set msgSet [new_CkMessageSet]
# Start with messages 1 through 10.
set success [CkMessageSet_FromCompactString $msgSet "1:10"]
if {$success == 0} then {
puts [CkMessageSet_lastErrorText $msgSet]
delete_CkMessageSet $msgSet
exit
}
# The identifiers that have already been processed and should be excluded.
set processed [new_CkMessageSet]
set success [CkMessageSet_FromCompactString $processed "2,4,6"]
if {$success == 0} then {
puts [CkMessageSet_lastErrorText $processed]
delete_CkMessageSet $msgSet
delete_CkMessageSet $processed
exit
}
# Remove the already-processed identifiers from msgSet.
CkMessageSet_Subtract $msgSet $processed
# Show what remains.
set remaining [CkMessageSet_toCompactString $msgSet]
puts "$remaining"
# Output: 1,3,5,7:10
delete_CkMessageSet $msgSet
delete_CkMessageSet $processed