Tinderbox Forum

(yet) another agent scope issue

Sorry for the basic question. After a long time without TBX I’m getting onto it again and forgot some basics. Issues of “scope” are the ones more difficult to me.

I have several original notes (T1,T2,T3 on the first TASKS container; T4 on the second TASKS container) and I’d like AGENT1 to retrieve only T1,T2,T3, and AGENT2 to only retrieve T4 – i.e. the notes inside the TASKS container, child of the agent’s parent, which have a given $prototype.

I’m trying with the query

descendedFrom(parent(that)) & $Prototype==“somePrototype”;

but the two agents collect all notes. Help appreciated. I really need to grasp queries and scopes.

2020-03-16_10-12-10_PM

Why not begin by collecting all the tasks by the explicit path?

Agent 1: inside(/PROJECT1/TASKS)

Agent 2: inside(/PROJECT2/TASKS)

Try that. Does it work as expected? Great! We can improve it. Or maybe not? We can clarify what’s wrong.

This is a common pattern. When agents aren’t right, begin by writing an agent that does at least part of the task, and that it so simple that it cannot possibly be wrong.

1 Like

What is ‘that’ in this context? I assume you’re trying to refer to the parent of the agent in which case the query syntax is:

descendedFrom(parent(agent)) & $Prototype=="somePrototype"

For agent ‘Agent1’, querey term descendedFrom(parent(agent)) refers to container ‘Project1’

Note also:

  • the ‘that’ designator is intended for use with find() which is not used in agents as the agent query is essentially a ‘find’.
  • queries, in agents (or find or if()) do not use semi-colon terminators. The latter are used in action code to delimit discrete expressions with the overall section of code. IOW: $Color="blue";$Width=5; is one action containing two discrete expressions, ore setting the note’s colour, the other its map icon width.
  • T1 would more usually and more understandably be described in Tinderbox as being ‘in’ a container rather than ‘on’ a container.
1 Like

Yes, explicit path does work, but as I am intending to have lots of projects :slight_smile: I’m looking for a programmatic solution to save time.

Thank you. For the solution and the (as always) explanation. I’ve used ‘that’ before but you are right, it was only with find().

OK. Progress! But we don’t want to keep working out the explicit path; we want the relative path. “Find the tasks that are in the tasks container that is my sibling”

Agent 1 before: inside(/PROJECT1/TASKS)
Agent 1 after : inside(tasks(parent(agent)))

All things being considered, though, I always stop when tempted to parameterize agents this way. You can do it! It’s fine! But when you do this, Tinderbox is whispering in your ear: “Is this something you can do with attribute browser? With cross tabs? Is this answering a question you know you need, or is it premature formalization?”

But if the answer is, “yes, this is a question I want to ask!” then it’s not that hard.
tasks(parent(agent)) is simply “the tasks contains that is inside the parent of the agent.”

1 Like

Thank you. That is very true. Tinderbox is so open handed that there are so many ways of reaching to a solution. Sometimes you complicate because you didn’t know an easier alternative, other times because you want to make a very complex script just to brag :slight_smile:

EDIT: and I never thought it would be this quick to put your thought into practice. I just wanted to isolate some notes from their descendants to output a clean timeline view. BUT timeline view has the option not to include descendants. So … turns out this was really unnecessary! But still good from a learning perspective.

1 Like