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
Sibling trouble (Read 2165 times)
Alastair
Full Member
*
Offline



Posts: 42
Christchurch, UK
Sibling trouble
Mar 09th, 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?

Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Sibling trouble
Reply #1 - 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.
Back to top
 
 
WWW   IP Logged
Alastair
Full Member
*
Offline



Posts: 42
Christchurch, UK
Re: Sibling trouble
Reply #2 - 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.
Back to top
 
 
  IP Logged
Alastair
Full Member
*
Offline



Posts: 42
Christchurch, UK
Re: Sibling trouble
Reply #3 - 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!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sibling trouble
Reply #4 - 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.
Back to top
 
 

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