Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Links and actions
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1459022593

Message started by John-Paul Bogers on Mar 26th, 2016, 4:03pm

Title: Links and actions
Post by John-Paul Bogers on Mar 26th, 2016, 4:03pm

Hi,

I tried to find the solution but I don't understand the info in the tbxref file....
I would like to set the value of an attribute depending on the value of an attribute of a note that links to this note.
Thus:
I have a note with the title of a book and an attribute called author. I have another note pointing to the first with a link (type "author") with the name of the author in it. How can I copy the value of the name of the author in the author field of the book note?

thx

JP

Title: Re: Links and actions
Post by Mark Anderson on Mar 26th, 2016, 7:05pm

So you have a note for a book (A) and $Author is set to the name of the author of that book. Another note (B), about the same book is, is linked to that book note with the link type 'author'.

Assuming B only links to single note using a link of type 'author' , then to set B's $Author to A's $Author value, use tht following rule in B (code tested in v6.5.0):

$Author=$Author(find(linkedFrom(that,"author")))

Although we're running the code in B, and B links to A, the logic of the linkedTo/linkedFrom operators is that it is the target note (i.e. A) that is tested. Thus we use 'linkedFrom' here, perhaps counter-intuitively - it certainly catches me out every time I use this family of codes.

Note too, this use of the 'that' designator. This is due to the way find() works.  If you were to use 'this' then the code would test is A links with A (instead of B as you desire to test).

If B were to have 'author' typed links to more than one note, B would take the $Author value of the linked-to note with the lowest $OutlineOrder value.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.