* Request help with maintaining Flags for individuals

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
avatar
evinther
Platinum
Posts: 43
Joined: 15 Feb 2009 09:43
Family Historian: V7
Location: Denmark
Contact:

Request help with maintaining Flags for individuals

Post by evinther » 19 Nov 2021 15:46

Hello,

I’m writing a plugin to maintain custom Flags on a group of individuals, but I’ve come to the point where I need some help, plz.

I’ve started with three scenarios when adding a new flag:
1. The individual has no flags i.e. no Flags item/attribute in the property page and the INDI record has no _FLGS tag
2. The individual previously had one or more flags that has been deleted, but the (empty) Flags item in the property page persists.
3. The individual has (other) existing flags

For starters I’ve learned that the value of the _FLGS tag is a comma separated list of flag names, and I can read this by using the function fhGetItemText(ptrIndiRecord,'~._FLGS'), and I can then add my new project to the list (scenario 3)

Q1: However, I can’t work out how to set the new value for the _FLGS tag! My logic tells me that the construction below should do it, but alas not.
ptrFlagItem = fhGetItemPtr(ptrIndiRecord,'~._FLGS')
bOK = fhSetValueAsText(ptrFlagItem, strFlagNames)

Q2: Another problem I have, is how to determine if the individual has an existing (empty) Flags item? In scenario 1 i expect i need to create the _FLGS tag first, and link it, before adding it's value,. In both scenarion 1 and 2 the function fhGetItemText(ptrToIndiRecord,'~._FLGS') returns an empty string.

Regards
Erik

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Request help with maintaining Flags for individuals

Post by ColeValleyGirl » 19 Nov 2021 16:03

Have you looked at Flags Add and Remove Function?

avatar
evinther
Platinum
Posts: 43
Joined: 15 Feb 2009 09:43
Family Historian: V7
Location: Denmark
Contact:

Re: Request help with maintaining Flags for individuals

Post by evinther » 19 Nov 2021 18:27

Hello ColeValleyGirl,

No, I hadn't actaully seen this function. It works just perfectly.

What should we all do without helpful persons like yourself?

Thanks a lot!

Erik

Post Reply