Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 
Send Topic Print
Finding the first child of agent item aliases... (Read 4395 times)
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Finding the first child of agent item aliases...
Reply #15 - Apr 01st, 2016, 6:46pm
 
Re your last, I get it - sorry I misunderstood before. I tried this in a rule in Y2:

$MyBoolean = any(ancestors, inside("actionable projects"))

I used a rule just to make for an easier test. Regardless, it still fails. $MyBoolean is false. As it happens, I'm not sure if any() can be used in an agent query. Way back there used to be a discrete syntax for querying (see older aTbref versions if interested).

I think this is as far as we can divine this from a user perspective.  I think MB's the only one who can explain this further. I doubt it's a code bug (even if so by logical inference) so much as a limitation in the complexity/scope of the expression allowed as any()'s second input. Also, I know in some places the app needs to act defensively against recursive loops from unwitting user queries - testing aliases being a good vector for that.

It's late this side of the pond nad I need to finish up. Sorry we can't resolve this tonight, but it's been an interesting problem to consider. I look forward to seeing what MB's take on this is.  Smiley
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Finding the first child of agent item aliases...
Reply #16 - Apr 1st, 2016, 7:18pm
 
One of us is missing something. I assume it's me.

Quote:
X, Y and Z are projects. Only Y and Z are actionable as X lacks children. So far so good. Note that in the 'actionable projects' agent the aliases of Y and Z have no children.

Now, as I understand it, you want an agent [sic] that would, in this file, hold aliases to Y1, Y2 and Z1. That outcome is achieved by only those 3 notes, of all notes, matching the agent query. The query must resolve at note level, and you can use offset attribute references (i.e. a value of a given attribute but for a different note).


Yes, that's exactly what I want.

Quote:
But, sadly you can't, for instance, ask a note to resolve aliases of its parent. So the fact that Y and Z have aliases inside another agent is one thing we can't test from the context of Y1, etc.


I'm not asking to resolve aliases of the parent. I'm trying to call inside() (which supposedly accounts for aliases) in the context of the parent using eval() or any().

Quote:
The nuance here is that I say, "but inside("actionable projects") is true for Y" Well it is for Y, but not Y1. When you test for the container of Y1's parent it is always 'projects'. There isn't a construct to say "if my parent or any of its aliases are in inside(something)" and that's what you need.


I don't think that's what inside() does. But when combined with eval() or any(), I think it would.

So it's not that Y1 is inside("actionable project's"). It's that Y1's parent is inside("actionable projects"). That's been the whole point from the very start.

I have a note. And I want to ask, "Is my note's parent inside('actionable projects')?" I can think of several ways to express that idea... none of which actually work Smiley

Anyway I feel like I'm just going around in circles at this point. I'll send a support request to Mark B and see where that takes things.
Back to top
 
 
  IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Finding the first child of agent item aliases...
Reply #17 - Apr 1st, 2016, 7:22pm
 
Quote:
I used a rule just to make for an easier test. Regardless, it still fails. $MyBoolean is false. As it happens, I'm not sure if any() can be used in an agent query. Way back there used to be a discrete syntax for querying (see older aTbref versions if interested).


Oh. It's unclear to me then what code is available in agent queries, and what isn't. I see any() in the full operator list. Upon closer inspection, it says it's a non-query boolean operator (and I have no idea what that is). Presumably a boolean operator that can't be used in an agent query?

I still think eval() should work here then. It did for a similar problem I posted a while back, though I'd be lying if I said I understood why. I have a theory (the second argument is evaluated in the context of the first argument), but that is supported by the end result rather than anything in the documentation (which doesn't show it being used the way I did).
Back to top
 
« Last Edit: Apr 1st, 2016, 7:24pm by Pat Maddox »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Finding the first child of agent item aliases...
Reply #18 - Apr 2nd, 2016, 12:51pm
 
any() takes 2 arguments. The first is a list of paths or titles ($Path or $Name) comprising at least one item but usually two or more. The second item is a test value. The value is resolved to a true or false result. The most normal usage (and probably the design intent) is an equality test (==) that a given attribute value is held by each list item as it is processed, e.g. $MyString=="Naiad".

This is where things get blurred. Pre v4.6, queries only existed in agents and if() statement and used a range of specific query operators. As you will see from this link, that would have included the '#inside()' test. From v4.6, the '#' prefix for these operators were dropped and they were treated as action code.

I relate all that as the second term of any() is an action code expression. At one time that would have specifically excluded a query (even though those too resolve to a true or false result). The best explanation for any(ancestors, inside("actionable projects")) not resolving to a true outcome is the historical quirk that inside may not be an acceptable expression. In hindsight that was also the (unstated) logic informing my earlier answers.

The latter makes sense, based on the history of the app but, I repeat, your fellow users can't see far enough under the hood to resolve this sort of issue. You genuinely need to contact support to get chapter and verse.

~~~~~~~~~~
Quote:
I'm not asking to resolve aliases of the parent. I'm trying to call inside() (which supposedly accounts for aliases) in the context of the parent using eval() or any().


Um, I think you are (without wishing to sound argumentative). The object that would return true for the inside test is not the parent of the task but an alias of the parent. so if those aliases aren't resolved tested, then then the inside() test would fail.

The description 'non-query boolean operator' should be clearer in terms of the history, related above, about the historic difference between query (only) operators and action operators. any() is (a) not an (ex-)query operator, but works on resolving a boolean result from evaluation of the second input parameter.

eval() I've never really understood - and I'm not sure it's documented correctly in my aTbRef notes. As it is, it's my best guess as to how it works. I try eval() quite often when all else fails. |sometimes it works, sometimes not, but it's never clear as to why!


[edit for typos]
Back to top
 
« Last Edit: Apr 3rd, 2016, 6:17am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Finding the first child of agent item aliases...
Reply #19 - Apr 2nd, 2016, 8:06pm
 
Quote:
Um, I think you are (withuot wishing to sound argumentative). The object that would return true for the inside test is not the parent of the task but an alias of the parent. so if those aliases aren't resolved tested, then then the inside() test would fail.


I get the sense that we're just talking past one another at this point. Because no, I don't see it like that.

I have a note called Child. It's in a container called Parent. When I evaluate inside() in the parent's context, then according to the documentation I would expect it to return true because an alias of the parent is inside the agent I specify (this is point 2: "an alias of A [the note's parent] is inside X [the agent]".

But I've now posted the same link to the same documentation several times, and made the same point repeatedly... I'm not convinced this is going anywhere productive at this point.

And it's clear to me that I don't understand how inside() is designed (not just how I think it should work!). I've created a simple example that shows it behaving completely differently from what I expect.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Finding the first child of agent item aliases...
Reply #20 - Apr 3rd, 2016, 8:15am
 
1) Any expression that returns a value can appear in a query. (Very, very long ago, queries had a separate syntax. That's ancient history now.)

2) I believe part of the difficulty here lies in the special semantics of inside().  The expression inside(theNote) is true if this is a child of theNote, or if any alias of this is a child of theNote.  

3) I've just returned from a long trip, and hope to address the underlying question shortly.
Back to top
 
 
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Proposed Solution 1
Reply #21 - Apr 5th, 2016, 1:52pm
 
Recap: We have a container /projects that holds two kinds of notes. Task notes represent things we can do; tasks have no children. Project notes are containers that hold tasks and other projects. From time to time, we might decide that a task actually requires several steps, and to it becomes a project. Alternatively, a project might become a simple task.

We want a list of all the tasks.

A solution:

   query:  descendedFrom(/projects) & $ChildCount==0
Back to top
 
 
WWW   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Proposed Solution 2
Reply #22 - Apr 5th, 2016, 2:35pm
 
The first solution is fine if all the notes in /projects are either a Task or a Project.  What if we want to have some notes that are other things -- shopping lists, emails, epigrams?

Let's create two prototypes, Task and Project.  A Task has a rule:

   Rule:  if($ChildCount) {$Prototype="Project"}

A Project also has a rule

   Rule:  if($ChildCount==0) {$Prototype="Task"}

Both Project and Task have an OnAdd action:

   OnAdd: $Prototype="Task"

So, adding a note to a project or a task initially sets the new note to be a task; if it's not a task, you can change the prototype or just remove it.

Well make the top-level container /projects a Project, too, so it gets the rule and onAdd action.

Now, our agent query is trivial

    query: descendedFrom(/projects) & $Prototype=="Task"
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Finding the first child of agent item aliases...
Reply #23 - Apr 5th, 2016, 6:18pm
 
FWIW, I find I use prototypes a lot. It gets round the problem like suddenly finding tasks need to nest so you can't just depend on parent/child propinquity.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Finding the first child of agent item aliases...
Reply #24 - Apr 5th, 2016, 6:45pm
 
Quote:
Let's create two prototypes, Task and Project. A Task has a rule:

Rule: if($ChildCount) {$Prototype="Project"}

A Project also has a rule

Rule: if($ChildCount==0) {$Prototype="Task"}

Both Project and Task have an OnAdd action:

OnAdd: $Prototype="Task"

Am I right in thinking that this is the solution we hammered out a while ago, when I was floundering trying to come up with a task/project discriminator? In any case, it is what I now use.
Back to top
 
 
  IP Logged
Pat Maddox
Full Member
*
Offline



Posts: 66

Re: Finding the first child of agent item aliases...
Reply #25 - Apr 15th, 2016, 5:15am
 
I've come around to the idea that it's important to set metadata and query it directly, rather than try to query associated notes. It definitely suits the Tinderbox model better... which is evident in a) complexity of agents / queries and b) when scaling up to thousands of notes.

Thanks Mark A for your patient help, and Mark B for weighing in.
Back to top
 
 
  IP Logged
Pages: 1 2 
Send Topic Print