DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMsgSet
Variant vProcessed
Handle hoProcessed
String sRemaining
String sTemp1
Move False To iSuccess
// 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.
Get Create (RefClass(cComChilkatMessageSet)) To hoMsgSet
If (Not(IsComObjectCreated(hoMsgSet))) Begin
Send CreateComObject of hoMsgSet
End
// Start with messages 1 through 10.
Get ComFromCompactString Of hoMsgSet "1:10" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMsgSet To sTemp1
Showln sTemp1
Procedure_Return
End
// The identifiers that have already been processed and should be excluded.
Get Create (RefClass(cComChilkatMessageSet)) To hoProcessed
If (Not(IsComObjectCreated(hoProcessed))) Begin
Send CreateComObject of hoProcessed
End
Get ComFromCompactString Of hoProcessed "2,4,6" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoProcessed To sTemp1
Showln sTemp1
Procedure_Return
End
// Remove the already-processed identifiers from msgSet.
Get pvComObject of hoProcessed to vProcessed
Send ComSubtract To hoMsgSet vProcessed
// Show what remains.
Get ComToCompactString Of hoMsgSet To sRemaining
Showln sRemaining
// Output: 1,3,5,7:10
End_Procedure