Which value(s) for $EndDate?

(Andreas Grimm) #1

What am I doing wrongly?

if($Checked=true){$Badge=Check mark; $EndDate=now} else {$Badge=clock; $EndDate=never};

Using values such as “now/today/current” always results in $EndDate being updated every minute; which, of course, I don’t want. I just need to log the $EndDate and then have it remain unaltered.


(Mark Anderson) #2

Um , that code looks wrong. Strings are quoted (and built-in badge names are lowercase):

if($Checked==true){$Badge="check mark"; $EndDate=date("now")} else {$Badge="clock"; $EndDate=;);

(Andreas Grimm) #3

well, @mwra, the code you kindly provided does not do the trick as far preventing $EndDate from being update every minute is concerned.

And, surprisingly, badge names work, too, if not lowercase and they don’t seem to need “quotation marks” either. Strange? Or just forgiving - codewise?

(Mark Anderson) #4

The latter, or in relation to quotes. The badges is interesting as I previously understood them to be case-sensitive. I suspect they are but if no match Tinderbox probably silently tries a case-insensitive match.

I didn’t have a chance to build a test for your code last night so my post was just testing for a code syntax error.

I think the functional error is your ‘if’ test. I suspect you want to only set the current time if $EndDate_ is not already set_. If so, your test should be:

if($Checked==true & $EndDate!="never")...

That way, checked notes with an EndDate aren’t reset.

(James Fallows) #5

In addition to @mwra’s always-authoritative advice, there’s another trick, just in case you (@andreas) are not aware of it or have forgotten about it. It’s the |= operator, the “pipe” symbol followed by the equal sign.

If the action part of your agent says the following:


Then the value for $EndDate will be updated only if it hasn’t already been assigned a value. Otherwise the value remains what is already there. It’s a different way of testing for an empty / default-value / unassigned field (recognizing slight differences among these).

The way I think of the |= operator, which I use all the time, is that it assigns a value where there isn’t one, but it doesn’t mess up any value you have intentionally assigned. aTbRef has the more detailed explanation here.

(Andreas Grimm) #6

it does work just as you said, @JFallows, and just as I need it to. Thanks you!