Can an agent apply a stamp?


(Galen Menzel) #1

Hi all,

Is there a way for an agent to apply a stamp? I’ve defined an agent that applies some actions, and occasionally I want to be able to manually apply the same actions with a stamp. So now I have the same code in my agent and in a stamp. Is there a way for the agent to just apply the stamp so that I don’t have this code duplication?

Thanks!

Galen


(eastgate) #2

This once was common, but using stamps in actions became so rare that we dropped support for it in Tinderbox Six. There’s not much harm in it, though, so we’ll turn on support for it once more in 7.0.2 – the action

stampname

invokes the corresponding stamp.

Another approach to avoiding duplication would be to let the agent do all the work. You might have an agent now with a complicated query and action. Split it in two, adding a new boolean attribute $NeedsToBeProcessed:

Query: (something complicated)
Action: $NeedsToBeProcessed=true;

Then a second agent performs the complex action:

Query: $NeedsToBeProcessed==true
Action: (some complex action);$NeedsToBeProcessed=false;

Now, your stamp doesn’t need to duplicate the action!

Stamp: $NeedsToBeProcessed=true;

In passing, though, I’d suggest that actions that are complicated enough to make one worry about duplication may be Tinderbox’s way of suggesting that you’re doing something the hard way!


(Galen Menzel) #3

Very interesting, Mark — thank you!

I’m mostly just messing around with changing appearance attributes when marking tasks as complete. I started using agents (to update the attributes when $Checked is true), and then started investigating stamps after I got bitten by some agents stepping on each others’ toes. But I see now that I was failing to properly serialize their actions with an action-setting flag.

I suppose agent queries must be quite lightweight to consider instituting a persistent query rather than a one-off stamp. Is there a resource where I can read about agent performance characteristics?

The actions I’m working with aren’t that complicated — just setting appearance-related attributes, plus moving notes from one container to another. But if there’s a nice way to avoid even a small amount of duplication I’d like to do that, if the cost is low enough. It seems that here it is.

Thanks for your quick and illuminating response!

Galen