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
Multiple conditional attribute assignment (Read 2460 times)
MJ Mastroianni
Full Member
*
Offline



Posts: 36

Multiple conditional attribute assignment
Jul 20th, 2014, 6:17pm
 
Note: I've already submitted a question concerning concerning the firing of actions when moving a note within the inside of an adornment in TB 6.0.2 to Eastgate (which has been assigned an issue number.)

My question is simply, can I have multiple conditional actions in an adornment? For example, how do I get the following behavior:

If a note's $Color is not red and moved into an adornment, change its $Color to red. If a note's $Color is red and moved into the same adornment, change its $Color to poppy. (Thus a note's color will toggle between red and poppy when dragged in and out of the adornment.)

Am I limited to a single if/else clause? Would it be possible to have, say, 4 or 5 conditions tested for that execute additional attribute assignments?

Deeper additional question: can an adornmennt inherit this behavior from a prototype adornment? What is the required conditional then?

Thanks in advance for advice áSmiley
Back to top
 
 
  IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Multiple conditional attribute assignment
Reply #1 - Jul 21st, 2014, 12:44am
 
I will leave it to one of the Marks to offer specific how-to guidance. But for the threshold question of whether TB can handle complex or conditional or chained queries, my experience is Yes. If you get the right syntax, you can refine this as much as you would like. á
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Multiple conditional attribute assignment
Reply #2 - Jul 21st, 2014, 6:03am
 
An adornment can use a prototype - it doesn't have to be an adornment though it can make more sense to have a prototype of the same type.

Can an $OnAdd have more that one condition? Yes:

if(conditionA) {
  ůsome code;
} else {
  if(conditionB) {ůsome code;
     if(conditionC) {
        ůsome code;
     }
  }else{
     ůsome code;
 }
};
if(conditionD) {
  ůsome code;
};


Notice that in the case of test 'conditionD' that it runs entirely separate from and after the other 3 nested tests.

if($Color=="red") {
  $Color="poppy";
} else {
  $Color="red";
}


Although notes may start of as any color, those notes interacting with the adornment will end up either red or poppy.
Back to top
 
 

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



Posts: 36

Re: Multiple conditional attribute assignment
Reply #3 - Jul 23rd, 2014, 1:13am
 
Thank you, that was very helpful Smiley

Cheers,

Mike

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print