Tinderbox v10 Icon

Break the code into discrete steps

An action can be as simple as setting a new $Color value, but in reality it may involve multiple expressions (think discrete actions in the same stored bit of code. Also remember that dot-operators condense a whole series of tasks into one expression.

Test as the smallest scope you can. Once confident the values resulting are as expected, all the parts can be joined back together. A common mis-step when debugging a failing action is not to tear down far enough and in so doing miss the step where a failure is occurring.

Chained operators

So, an expression might get a list of data via a collect using a custom find() query, .sort() it and de-duplicate it via .unique() and then format it as a custom string via .format(). Essentially, there are five activities there any of which can be tested separately:

Agents

If using agents with an agent action, it is a good idea first to check that the agent is finding (aliasing) the correct notes before then adding the action code. Also consider turning the agent off whilst actively editing the action/rule/edict.

Rules and edicts

If editing code, disable rules and edicts so that half-written code is not run. Important to note is that if editing a prototype's rule or edict, it is better to remove all the code, edit it in a code note and re-insert when done. This is because $RuleDisabled and $EdictDisabled are intrinsic and not inherited. with long/complex actions especially, this increases the chances of large numbers of notes trying to run incomplete code.

A common issue with prototype use is that during test/tune of a rule/edict the code gets edited in an inheriting note (wrong!) rather than in the source prototype. A query for use of the prototype (in $Prototype) & hasLocalValue() can help. For notes using prototype "Person" this query will match all notes with that prototype which have locally set $Rule value:

$Prototype=="Person" & hasLocalValue("Rule") 

This ought to match no notes but if it does match any, those notes need their rule reset ($Rule=;). Edicts—indeed, any attribute—can be checked for broken inheritance.