Working with numbers + equal and less than


(Rene Trappel) #1

Hi,

I try to filter notes of a particular prototype (representing courses, in this case) with one numeric variable (representing participants) being 4 or less and apply the action $Color=“red” to them. If I use this query in attribute browser:

$Participants<=4 & $Participants!=“0”;

TB correctly shows me the two courses with less than 5 participants (I’ve added $Participants!=“0” because I do not want to see the prototype). If I use this as an query for an agent TB finds 17 items, some with more than 50 participants. What am I doing wrong? Thanks.


(Mark Anderson) #2

What is the scope of the attribute browser - i.e. is the container set to “entire document”. If it is not, the attribute browser is not looking at the entire document but only the children and descendants of the selected container.

To make the agent query the same as to one for attribute browser. If AB view is scoped to container ‘Project X’, make your agent query:

descendantsFrom("Project X") & $Participants<=4 & $Participants!=0

As $Participants is presumably a Number-type attribute, you don’t quote the number values such as the 4 or 0.


(Rene Trappel) #3

The scope was set to “entire document”, there is actually no container in this document yet.

Here are some screen shots that might better reflect the problem.

  1. To prove that participants is of the type “number”.

  2. In attribute browser, the query being $Participants<=4 & $Participants!=0;

  3. Results in:

  4. Adding quotation marks:

  5. Results in:

  6. But the most confusing part is this picture of the agent (1/2):

  7. and with the other query term (2/2)

Notice the subtile difference between the two queries (17 vs 18 items).


(Mark Anderson) #4

Thanks for the clarification on scope - sorry it was the logical first test! Meanwhile, I’m not quite sure what the main problem but for avoidance of doubt, if using a number (i.e. Number-type attribute) do not quote the value. Also, when writing a query, as opposed too an action, you don’t use a semi-colon at the end.

That said it shouldn’t matter (i.e. Tinderbox generally correctly guesses you intent). Using the built-in $MyNumber and 3 notes with values 0, 3 and 5 I tested and agent with:

$MyNumber<=4 & $MyNumber!=0
and
$MyNumber<=4 & $MyNumber!="0"

Both gave the expected single match. Nonetheless, the first version is the code to use. As you wish to match values 1 through 4 you could try this query:

$MyNumber<5 & $MyNumber>0

It looks as if your AB view is filtering out items with no prototype set, whereas the adornment isn’t, although that isn’t expected using the settings you show.

Can you post a link to a test TBX that shows the problem?


(Rene Trappel) #5

Holy smokes, it was the semi-colon that put Tinderbox off!

I was just putting together a sanitized version of the document, entered the query and everything worked as it should be. Slightly confused I noticed that the only difference was that this time I used your version of the query (without the semi-colon). And, sure enough, when I used $Participants<=4 & $Participants!=0 it worked in the original file as well.

Thanks for the help (and the offer to send a test file) and sorry for the confusion. Perhaps a later version of Tinderbox could remove the semi-colons from the examples in the Action Inspector :slight_smile:


(Mark Anderson) #6

I’d agree. The examples on the Action Inspector shouldn’t have semi-colons. I’ve passed that on.