Agent syntax question

Hi, all,
I want to create an agent that will constantly gather notes that I have marked with a string (what in many apps would be called a tag, though in Tinderbox ‘tag’ seems to be associated with bibliographic materials). My attribute is called majortopics and it has a number of different strings entered as its value in different notes.

So, I wanted to collect all notes in which majortopic includes among its strings the string “privacy”. Basing my attempt on the “Getting Started” doc, I created an agent whose query is

   $majortopics.contains("privacy")

This does not work.

So, my questions are:

  1. Why doesn’t it work?
  2. Where can I obtain a more detailed explanation of Tinderbox syntax, so that I can make better guesses about how to create agents to do what I want?

Thanks
David

$majortopics.contains(“privacy”)

This looks OK to me. The most common problems here would likely be:

  1. Attributes are case-sensitive, so “majortopics” is not the same thing as “majorTopics” or “MajorTopics”.

  2. I expect that $majortopics is meant to be a set or a list. Double-check that it is.

  3. Remember that quotation marks in Tinderbox actions (and most computer languages) are straight, not typographic or “curly” quotes.

I appreciate that when terminology varies from what you are used to, things can get confusing. In Tinderbox, the term ‘tag’ is generally referred to as a common synonym for a keyword - people often talk of ‘tagging’ their photos when they apply keywords for searching purposes. As such, Tinderbox has a ‘Tags’ attribute as part of the ‘References’ group of built-in attributes as data copied from reference managers usually includes tags (i.e.search keywords).

If you want more info on how to use Tinderbox action codes I’d recommend this page as a starter (disclaimer: I’m aTbRef’s author, but I write it as a free public resource)).

The use of ‘string’ is the normal programming sense where it refers to what a non-programmer might call ‘text’. Tinderbox has 12 different attribute data types. I think what you’re calling a ‘string’ would, in Tinderbox parlance be called an attribute value or (in the query context) a search string

Note that attribute names are case-sensitive, so MajorTopics, Majortopics and majortopics would be treated by Tinderbox action code as referring to 3 discrete attributes. Assuming your attribute is called majortopics, and is the default data type of String-type then the query worked for an attribute value of ‘privacy’ and for ‘some privacy’. So, I’m guessing you may be using a multi-value data type such as List or Set. In that case, e.g. as a List type, you query works for a value of ‘privacy’ but not ‘privacy’. This is because you can’t do partial matches on List/Set type attributes - see more here.

Hi, thanks as ever for the quick answer.

  1. I am aware about the case issue and carefully checked that. Not the problem here.
  2. I don’t think I understand this. Entries in the $majortopics box in each note are strings, each string separated from the next by a semicolon. Is that the issue? Perhaps I don’t know how to properly create a list.
  3. Quotation marks are not curly.

I bet my problem is somewhere in item 2!

David

Hi, yes, it must be that I am using Lists or Sets wrongly. Thanks for the links! I suspect they will help clear that up.

If one can’t do partial matches on lists, then what is the best way to do them? Ie, if a note has 5 keywords, how do I tell an agent to react if it sees only one of those words?

David

Hmmm. Looks like I should be using String.contains(“privacy”) rather than what I tried.

Yes, it is likely #2 given your other answers. What data type is $majortopics? It is likely a String, List or Set type. You can check that in the Document Inspector (see here). My hunch is you’ve made a List or Set type and these only allow matches to complete list items, for reasons explained here.

If still having problems can you:

  • State the attribute data type you are using
  • The value or list of values that you expect to match the query but don’t

That gives us more of a frame of reference to solve your problem.

Typically, $Topics would be a set. One note might have topics

Tacitus;Pliny;Sallust

Another might have topics

Pliny; Marcus Aurelius; Galen

In this case, $Topics.contains(“Pliny”) would be true for both notes, and $Topics.contains(“Tacitus”) will be true for one note. $Topics.contains(“Marcus”) is true for neither note, because neither set contains the element “Marcus”. (The second note contains “Marcus Aurelius”, but not “Marcus”.

No, not if your attribute is called ‘majortopics’. If you’re trying ‘string’ after looking at my page on action code, please understand it is written to indicate the data-type of attribute that uses that type of function. This is because .contains() works slightly differently in outcome on a String-typecompared to using it on a List or Set.

Problem solved. The I put the query into the Agent Action box instead of the Query box. A lesson in the important difference between those two concepts.

Thanks for the replies, in any event. I’ve learned some important things from them.