Agent to gather documents with different prototypes

Dear TB users,

I have four types of documents I am dealing with. Each has different key attributes. The $Prototypes are:

Document: A
Document: B
Document: C
Document: D

I want an agent that will pull together all the documents. I know the long way to do it. What is the short way to pull together all documents that have a $Prototype that includes the word "Document”?

Thanks.

BH

$Prototype.beginsWith("Document")

For each note using a prototype, the $Prototype attribute holds the prototype’s name, so we search that. I’ve used .beginsWith(“Document”) rather than .contains(“Document”) as the first is a literal match and the latter a regex (i.e. uses more calculation. If possible, always go with the smallest scope and least cpu-intensive queries, at least do so once your documents grow in size.

If many notes have no prototype, you may get a more efficient query with:

$Prototype & $Prototype.beginsWith("Document")

IOW, first match only notes with a prototype set and within that list then search for the specific string in the prototype’s name.

Seems to me the “more efficient query” would burn more cycles by looking twice than just looking once. Especially since Tinderbox still has to query all to determine whether $Prototype == "" .

Irrelevant of course in most documents on most well configured modern machines.

I doubt that the second query would have a noticeable impact on performance.

Indeed, my understanding is that a query resolves term #1 first, then term #2 against the result of the previous test. This does pay off if the last term is a regex but in small documents the difference is moot. The point in my answer is to try and look to the (obvious) next/arising question, as in “I tried that but now I have a new question”. I’d rather write the longer answer once over and hopefully cover most/all the arising issues in one go. Not least because initial questions here are not the actual question but a simplified context to make it easier to ask the question.

However, docs that start small may grow over time so it helps to know what can improve overall performance. Ironically, I’d already suggested discussion of the broader performance topic for today’s meet-up.

Thanks. I am going to have to get with the . commands like “.beginsWith”. Where are they listed? What would I do if I wanted the agents to pick up “Document : A” & “Document : C” but not "“Document : B” & “Document: D”?

BH

My listing of action codes is here (and it’s a link at the top of every aTbRef page.

A list of dot-operators is here, but note many are alternatives of older versions, e.g. format() vs. .format.

So why the difference? Chaining makes the process more understandable. Less say the to get the output you want, you need to apply function1(), function2(), and function3() in that order to note “Some Note”:

$AnAttribute = function3(function2(function1("Some Note")));

The same, as chained dot operators:

$AnAttribute = "Some Note".function1().function2().function3();

In the first case you have to read from inside outwards to work out the process. In the latter case you read from left to write.

Note: not all action code operators can be used as dot-operators, see the above links for more.

$Prototype.beginsWith("Document: A") | $Prototype.beginsWith("Document: C")

or

$Prototype.contains("Document: A") | $Prototype.contains("Document: C")

or

$Prototype.contains("Document: (A|C)")

Note that .beginsWith() cannot use regular expressions as in the last example.