Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Moving to Tinderbox 6 >> Add a value to attribute rather than replace it?
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1415454827

Message started by BCrane on Nov 8th, 2014, 8:53am

Title: Add a value to attribute rather than replace it?
Post by BCrane on Nov 8th, 2014, 8:53am

A basic question that has me stumped.

I have a user attribute that is a set. I know how to assign the attribute to a value, (e.g. $Keyword=("work")) but I can't figure out how to add an additional value to the existing one. For example, how would I add "urgent" to "work" so the attribute value becomes  "work;urgent" when I don't know what the existing attribute value is?

Title: Re: Add a value to attribute rather than replace it?
Post by J Fallows on Nov 8th, 2014, 10:11am


Quote:
For example, how would I add "urgent" to "work" so the attribute value becomes  "work;urgent" when I don't know what the existing attribute value is?


I know that there is an easy way to do this, but right at the moment I forget the exact syntax. I also know that either Mark A or Mark B will know the right syntax! It would be some variant of an agent like this:
   Query:  $Keyword
   Action:  $Keyword=$Keyword+"NewValue"     [this is the syntax I am guessing at]

  Or an on-add action to the same effect. I await a report on the actual syntax to use. But I know this can be done, because I've used the approach before.

Title: Re: Add a value to attribute rather than replace it?
Post by Mark Anderson on Nov 8th, 2014, 12:18pm

@JF, is correct. To add a value to a list (List or Set type attributes) you set the attribute to itself (i.e. the existing value) plus the new values. Thus:

$Keyword=$Keyword+"New Value"

Want to add two (or more) values?

$Keyword=$Keyword+"New Value" + "Different Value"
$Keyword=$Keyword+"New Value;Different Value"

In the latter case the semi-colon tells TB you're adding two list values.

In the following, the parentheses won't make the code fail but aren't needed at all:

$Keyword=("work");

Use:

$Keyword="work";

The closing ';' is optional.  It's a good habit to acquire thuogh, if you're uncertain with action code as it tell TB "I've finished this expression". You do needed it if an action or rule uses several discrete action code segments. Here be both set a keyword and change a colour:

$Keyword="work";$Color="blue";

Here the first semi-colon is needed, but the second one is optional as no further code follows. This use of the semi-colon is separate from it's use a a value delimiter in the way TB stored lists (and shows those values as key attributes.)

Title: Re: Add a value to attribute rather than replace it?
Post by BCrane on Nov 8th, 2014, 2:06pm

Thank you both! This is clear and works great.

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.