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
Send Topic Print
linkTo aliases with $Name = a set of attributes (Read 1097 times)
B.Moreira
Full Member
*
Offline



Posts: 71

linkTo aliases with $Name = a set of attributes
Jul 04th, 2016, 6:15am
 
I have an agent called "container" which gathers two types of notes (plans & actors).

Inside the agent, I have the following notes:
- plan1
- plan2
- actor1
- actor2
- actor3

plan1 has "actor1;actor3" in its $Actor attribute (set, user defined).

I'd like plan1 to automatically linkTo actor1 and actor3 aliases inside the agent. I have defined as its rule:

Code:
linkTo(find(descendedFrom("container") & $IsAlias & $Name.contains($Actor(this))),"agree"); 



However, this makes "plan1" link to "actor1", "actor2" and "actor3" .. (shouldn't link to "actor2").

I must be confusing the scope of "this" ...

Can someone help? Thanks!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: linkTo aliases with $Name = a set of attributes
Reply #1 - Jul 4th, 2016, 9:58am
 
I'm not sure I've fully understood, but inside a find() is you want to pull an attribute from the note/agent running the find code, as opposed to each note being queried in the find(), you need to use the 'that' designator - see more.

Unless you have a note or agent called "container" (case sensitive) then the first part of your action doesn't make sense.

However, in testing this v6.6.1, I think there is a problem as this code fails if $Actor has > 1 value:

$MyList=find($Name.contains($Actor(that)))

I've reported this to support (before deliving deeper).
Back to top
 
 

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



Posts: 71

Re: linkTo aliases with $Name = a set of attributes
Reply #2 - Jul 4th, 2016, 10:29am
 
Thank you Mark. That's right. Code works but only for 1 value in the set ...
critical bug now that my Tinderbox year of updates ended a few days ago Sad
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: linkTo aliases with $Name = a set of attributes
Reply #3 - Jul 4th, 2016, 12:24pm
 
Indeed. As I can only test what doesn't work, I figured I'd try and find what's broken as opposed to assumed functionality before trying to think of a work-around. I did actually try an idea based around list.each() but there seem as issue with the value of the loop variable (akin to the need for a 'that' vs. 'this' designator). Some of these things get a bit complex. In fairness to the app, Tinderbox's action code is a case of macros+plus rather then IDE-minus and should be seen in that context.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: linkTo aliases with $Name = a set of attributes
Reply #4 - Jul 5th, 2016, 5:43am
 
Doh, the answer whilst simple is perhaps not intuitive until after the fact.  the core issue here is testing if a string ($Name of a note) matches any single value in a list ($Actor). You can't do that in action code - in that manner. But, as a list is stored as a single string of concatenated values, so the latter can contain, as a sub-string, the single item being compared. Sorry, that's convoluted.  this may make it clearer. Let's say we have $MyString of "cow" and a $MyList (or $MySet) of 3 values with a stored string of "ant;bee;cow".

$MyString.contains($MyList) fails because if seen as literal strings:

("cow").contains("ant;bee;cow")

is false. But, reverse things and test $MyList.contains($MyString) and we have success:

("ant;bee;cow").contains("cow")

So one 'error' in the original code was the test was reversed, you need to test $Actor(that).contains($Name). It may not seem like it but you are essentially asking , for the one currently tested "Does its $Name equal [sic] any value in the $Actor of the note calling the find()". Or in pseudocode: $Name==anyValueOf($List(that)).

Sidenote: Apologies for the long explanation (and which I'll abstract to relative parts of aTbRef in due course) but I think it useful for later readers.

Having fixed that, it exposes a further problem. If understood  correctly you want to make agent-based maps where the items on the map (not their originals) are linked - visibly. Originals and aliases can have their own discrete links. so, you need to do the linking via the agent action and not via a rule note as the latter runs in the original and in all the aliases. In testing, it seems hard to get the rule to distinguish if it is linking an original or an alias without giving very specific paths. However, ...

Luckily, we can do this via an agent. Note, this depends on a change early in v6.x whereby 'that' was correctly applied in an agent action. If we make our agent action this:

linkTo(find($Actor(that).contains($Name) & $IsAlias),"agree");

Each plan note alias on the agent map, links to the current map alias of any actor notes listed in the plan's $Actor attribute. Importantly, it doesn't link to actors in $Actor that aren't matched by the agent query, i.e. aren't included in the current map.

My test TBX is here (zip).

Edit: forgot to add don't think you'll need to update past the current v6.6.1 to do this. Agent actions correctly evaluate the 'that'  designator as from v6.5.0.
Back to top
 
« Last Edit: Feb 6th, 2017, 12:51pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print