I see a typo in your code, the first semicolon is after the first closing curly bracket. It should come before it. Thus, with code slit out for clarity:
if($Urgent==true){
$Color="red";
}else{
$Color ="cyan";
};
The .locisng semicolon on the last line is option if not other code follows. But is some other action followed, the semicolon is needed. Also Tinderbox generally is ifnored around control characters. however, to clarify intent, I think
if(query.){code}else{code}`
is much less ambiguous than, for example,
if (query.) {code} else {code}`
In the former, I think it is more intuiting that the condition and code apply to the if
command (including its optional else
branch). Generally, for anything other than the simplest of codes, I also use line breaks to show more clearly what code 'belongs to which branch and—where nested conditional test are used the opening/closing [ }
are correctly placed, so:
if(query){
code
}else{
code
}
As regards semicolons, this is fine:
if($HasSomeValue==true){
$Height = 2
}
but if there are two discrete actions, e.f. setting two different attributes, at minimum the first expression must end in a semicolon regardless of line breaks:
if($HasSomeValue==true){
$Height = 2;
$Width = 4
}
Separately, if code folows the if
a semicolon is needed as the whole if(){}
is treaded as an expression:
if($HasSomeValue==true){
$Height = 2;
};
$Badge = "ok";
Because I’m generally writing for non-exports my examples (unless I forget!) are verbose including semicolons after all expressions:
if($HasSomeValue==true){
$Height = 2;
$Width = 4;
};
This makes it clearer if line breaks are omitted:
if($HasSomeValue==true){$Height=2;$Width=4;};
or where there is an else
branch:
if($HasSomeValue==true){$Height=2;$Width=4;}else{$Height=3;$Width=6;};
In the latter case, the semicolon only goes after the final }
closing the else
branch of the if()
statement.
Also, you need to scope you queries. You don’t want to check all notes but—in this case I think—your task notes. For the latter I believe you use the built-in prototype “Task”.
If you want to check all tasks, you need a query that matches all tasks, e.g.:
$Prototype=="Task"
This finds all (and only) notes whose prototype is set to 'Task" regardless of urgency. Then use that agent’s action to do the selective work:
if($Urgent==true){$Color="red";}else{$Color="cyan";};
As the action is run separately on every current alias in the agent, non-urgent (Task) notes do match the else
branch in the action (I just confirmed this in v9.2.1):
Does that help?