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 >> Sibling trouble
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1425908615

Message started by Alastair on Mar 9th, 2015, 9:43am

Title: Sibling trouble
Post by Alastair on Mar 9th, 2015, 9:43am

Afternoon all, a simple question (I think).

I'd like to query a note's siblings to establish if any has a matching value.  As an example, if I have two containers, each with a Company prototype, containing one note for each employee:

A Company                    (Initials)
Arnold Bocklin                    (AB)
Charles Darwin                   (CD)
Charles Dickens                  (CD)
Ethan Frome                      (EF)
George Harrison                 (GH)

B Company                    (Initials)
Charles Aznavour                (CA)
Charles Bukowski                (CB)
Charlie Chaplin                   (CC)
Charles Dance                    (CD)
Charles Eames                    (CE)


I'd like both Charles Darwin and Charles Dickens to recognise that their respective initials clash, and set a flag that will remind me to resolve the issue.  They should pay Charles Dance no attention.

Having tried agents with little success, I'm now attempting to use the Rule of the Employee prototype to collect and query a list of sibling initials (forgive the longwinded attribute names!):

$name_SiblingInits = collect(sibling,$name_Init) ; if($name_SiblingInits.contains($name_Init)) {$name_InitsMatch="true"};

However, it seems querying siblings in this way returns the note's own value.  Is there an easy way to avoid this?


Title: Re: Sibling trouble
Post by Mark Bernstein on Mar 9th, 2015, 11:28am

Let's assume that notes are sorted by initials.  That means a duplicate would have

      $Initials(prevSibling)==$Initials(this)

But if a note has no elder sibling, $Initials(prevSibling) returns $Initials(this).  You can test that:

      $Initials(prevSibling)==$Initials(this) & $SiblingOrder !=1

Not tested, but this seems a sensible approach.

For modest numbers of people, I'd just use AttributeBrowser and scan for categories with more than one entry.

Title: Re: Sibling trouble
Post by Alastair on Mar 10th, 2015, 3:49am

Thanks for your advice. I think I was probably going about it the wrong way. Added a rule to the Company prototype that collects the initials of its children in a list, passes that to a set, and compares the the two values:

$staff_Inits = collect(child,$name_Init); staff_InitsSet = staff_Inits; if(($staff_Inits.size - $staff_InitsSet.size) > 0) {staff_InitsMatch = "true"} else {staff_InitsMatch = "false}";

Seems to work.

Title: Re: Sibling trouble
Post by Alastair on Mar 10th, 2015, 4:47am

Or, to cut the rule to the bone:

$staff_Inits = collect(child,$name_Init); $staff_InitsMatch =  ($staff_Inits.size - $staff_Inits.unique.size);

Where, if a duplicate is found, the rule returns a positive result to the boolean $staff_InitsMatch.

Right, I think I've done that to death.  Thanks for your help!

Title: Re: Sibling trouble
Post by Mark Anderson on Mar 10th, 2015, 11:47am

A quick side note re action code, group designators have been updated to more obvious values (sibling -> siblings, child -> children) although the old v4 era values still work. See more.

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.