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
Question about conditional assignments (Read 1826 times)
jfontana
Full Member
*
Offline



Posts: 23

Question about conditional assignments
Dec 25th, 2014, 3:56pm
 
Hi,

I'm trying to use a conditional statement to make the titles of notes that contain a certain expression change color. I created an Agent that has the following statement in the Action section.

if($Text.contains("insecure")) {$Color="red";}

I don't know what I'm doing wrong. Am I placing this in the wrong section? Is there a problem in the syntax?

If instead of this I have the following in the Query section

$Text.contains("insecure")

and the attribute $Color="red"; in the Action section, then everything works as intended.

For such a simple condition, this is not a problem and I can do it separately but I envision other situations where having conditional assignments would be needed.

Can anybody tell me what I'm doing wrong? Thanks.

JM
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Question about conditional assignments
Reply #1 - Dec 26th, 2014, 8:50am
 
Uf the initial agent only had an action, then nothing would happy. An agent must always have a query, otherwise there are no aliases inside the agent on which the action can run. Your second attempt worked as there was a query.

However, Yes, you can have conditional agents. Let's say you only wanted blue notes with 'insecure' in the $Text to run the action:

Query:   $Text.contains("insecure")
Action:   if($Color=="blue") {$Color="red";}

So I assume the original problem was the lack of an explicit query (as you'd presumed no query meant 'check all notes'). If not, just ask.
Back to top
 
 

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



Posts: 418

Re: Question about conditional assignments
Reply #2 - Dec 26th, 2014, 12:44pm
 
Quote:
I'm trying to use a conditional statement to make the titles of notes that contain a certain expression change color. I created an Agent that has the following statement in the Action section.

if($Text.contains("insecure")) {$Color="red";}


Just to follow on to Mark A's always-authoritative advice, this may potentially be clarifying.

- If you had a rule formulated in just the way you put, above if($Text.contains("insecure")) {$Color="red";} then that would work fine, it seems to me. A rule can be thought of as an all-in-one combo of some condition (which could be an "if(..)" formulation or presence in a container or some other factor) and some action. I believe that this formulation would also work if you made it an On-Add action, which is a kind of runs-one-time-only rule.

- But if you are doing it as an agent, then just as Mark A says, you would need to break this statement into its two components. The $Text.contains("insecure") part, minus the "if," would be the query portion of the agent. And the part setting the color would be the action portion of the agent.

If I have this wrong, one of the Marks can deliver the official verdict. But this is my understanding.
Back to top
 
« Last Edit: Dec 26th, 2014, 12:46pm by J Fallows »  
  IP Logged
jfontana
Full Member
*
Offline



Posts: 23

Re: Question about conditional assignments
Reply #3 - Dec 26th, 2014, 6:13pm
 
Thanks guys. Cristal clear answer and now that you say it, it makes sense. It takes a little time to get your mind wrapped around the way Tinderbox works. With great power comes steep learning curve.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print