Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Agent, Actions, Rules & Automation >> Question about conditional assignments
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1419540975

Message started by jfontana on Dec 25th, 2014, 3:56pm

Title: Question about conditional assignments
Post by jfontana on 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

Title: Re: Question about conditional assignments
Post by Mark Anderson on 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.

Title: Re: Question about conditional assignments
Post by J Fallows on 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.

Title: Re: Question about conditional assignments
Post by jfontana on 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.

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.