Tinderbox Forum

Agent Queries on Flags

I’m needing to create several agents based on Flags. For example, I have notes with flags like:

  • :heavy_check_mark:.green
  • :heavy_check_mark:.green/yellow
  • :heavy_check_mark:.yellow/green
  • :heavy_check_mark::heavy_check_mark:.green
  • :heavy_check_mark::heavy_check_mark:.green/yellow
  • :heavy_check_mark::heavy_check_mark:.yellow/green
  • ✘.green
  • ✘.green/yellow
  • ✘.yellow/green

What agent query would give me all flags that begin with :heavy_check_mark::heavy_check_mark: regardless of color?
$Flags.beginsWith("✔✔") and $Flags.String.beginsWith("✔✔") doesn’t work.

What query would give me all flags that have any green whatsoever?
$Flags.contains("green") doesn’t work.

Flags is a List type so you can’t use regex: see here. The string-ifying method described in the last part of the linked article may work

Would using Badges instead of Flags allow for the desired search types?

I don’t think so as I have multiple flags per note. Does this match your understanding?

I guess that would be a challenge if you need multiple badges per note.

Although it could be done by creating a badge for each desired combination, using a custom attribute of type Set, and then creating an Agent or Stamp to assign the custom badges based on the contents of the custom attribute.

It could be done but maybe not worth the effort. But a benefit would be that it is then visible in the outline view in addition to the map view.

Hey there. I’m not sure what font you use for the checks, but this worked with “@@”.

Beck FlagTest.tbx (103.5 KB)

That worked perfectly, Michael.

Now… why?

p/s. The :heavy_check_mark: is U+2714 “HEAVY CHECK MARK”

Update: I see exactly how it worked because I’ve been watching your wonderful videos this evening and found the answer here: https://www.youtube.com/watch?v=GPmqTZGRduw&list=PL6MVDtSfcKxd2XLpenMAd9H4VknDyn6oz&index=15

Much gratitude to you, Michael, for these short and easy to follow video explanations. :clap: :clap: :clap:

Just to tie the strands together, the technique in @satikusala’s demo is indeed the method I’d documented in the previous link.

In the demo, the list items are concatenated with a pipe | characters:


(BTW, in the demo, the agent omits the ‘$’ prefix. The agent works, but only due to legacy format support.)

Clearly, were that concatenator to be one of the characters used on your flags, then you’d use a different concatenator. So, you might change a pipe to a hash:

1 Like

To acknowledge Mark A, and others.

I appreciate all the positive feedback I’m getting for producing the videos; I accept the accolades and am grateful.

However, I, in no way, have done this alone and stand on the shoulders of the giants that have come before me and support me now.

@beck’s wonderful video inspired me. @eastgate’s patience with me has been laudable. @bmgphd got the ball rolling and his pushback inspired me to be better. We’d be nowhere without @Sylvaticus weekly meetup. @TomD’s detailed critiques have been exceptionally useful. And, then there s everyone’s comments on the videos; @pmaheshwari in particular inspired me to figure out how to improve the video and audio quality (a whole new skill set). @PaulWalters’s feedback, as well has been instrumental. @rtalexander got me into understanding runCommand and functional with regex.

And, then there is Mark A. aTbRef is a gift to the community. For me personally, Mark has spent tens of hours with me in one-on-one calls over the last few months as we grock Tinderbox and knowledge management.

To those not mentioned, gratitude goes out to you as well.

To all, thank you.


Whoops…did this mock file in 10 minutes before dinner. Thanks for catching the error. Here is a corrected file.

Beck FlagTest.tbx (94.8 KB)

1 Like

Yes, Mark, thank you!

And without your reference I’d be utterly lost in all I attempt to do in TB (truly).

I had a hard time with the section you pointed out… perhaps due to the verby nature of “format,” it’s association with “replace” and the caution to proceed with care. I was concerned I was reformatting my data. The explanation also assumes some base knowledge on regex that I don’t have, as well (I don’t know which symbols have regex meaning and I don’t). The turning point for me was the statement Michael made in the video where he said the code was temporarily creating a string on the fly that could be searched.


Great. That’s useful info I can action. Especially the part about not changing the source.

The problem with regex is you can’t simplify them. They do what they do, but there are online and Mac app resources for testing regex which helps with both learning and confidence (the online resources are largely free).

Reflecting the above, I’ve updated my notes replacements for strings and lists to make more explicit that the replace action does not affect the source—unless you use the output of the action to overwrite the source.

Put most simply, this does nothing:


You must apply it to something, like so:

$SomeString = $Text.replace("searchStr","replaceStr");

Now $SomeString is set to the output but $Text is unchanged. But if we set input as the output:

$Text = $Text.replace("searchStr","replaceStr");

The $Text is now changed, and being an action there is no undo (other than old copies of the file). Of course, the above behaviours apply not just to $Text but to any string-like source.