I am reading in a list of constituent attributes (tags) and only want to keep a subset of them. Here is how I attempted to do that.
DEFINE VARIABLE tagsToKeep AS CHARACTER.
tagsToKeep = "Business Contact,Celebrate 2015,Celebrate 2017,Celebrate 2019,Certificate - Former Holder,Non-MB Church".
/*do a bunch of stuff to get the cRecord which is one tag, often with spaces or other characters in it.*/
IF INDEX(tagsToKeep, cRecord) > 0 THEN
DO:
CREATE ttTag.
ASSIGN
ttTag.tag-code = cRecord
ttTag.constituent-id = ttAccount.pin-string.
ttTag.tag-name = cRecord.
END.
The trouble is that one of the tags is "Certificate" which is a substring of one of the strings in the TagsToKeep string -- "Certificate - Former Holder" gets included and created as a Tag. I only want to match on the strings that are essentially "whole word only".
Is there a (better) way to do what I want to do?
In your code, use LOOKUP instead of INDEX
IF LOOKUP (cRecord, tagsToKeep) > 0 THEN
(comma-) delimited lists are a key concept in the ABL.