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
Add a value to attribute rather than replace it? (Read 5807 times)
BCrane
Full Member
*
Offline



Posts: 22

Add a value to attribute rather than replace it?
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?
Back to top
 
« Last Edit: Nov 08th, 2014, 8:55am by BCrane »  
  IP Logged
J Fallows
Full Member
*
Offline



Posts: 418

Re: Add a value to attribute rather than replace it?
Reply #1 - 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.
Back to top
 
« Last Edit: Nov 8th, 2014, 12:18pm by J Fallows »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add a value to attribute rather than replace it?
Reply #2 - 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.)
Back to top
 
 

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



Posts: 22

Re: Add a value to attribute rather than replace it?
Reply #3 - Nov 8th, 2014, 2:06pm
 
Thank you both! This is clear and works great.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print