I have a bunch of notes with an attribute, ‘Tags’, being a comma-separated list of tags, sometimes quoted when containing spaces (eg, 'this, that, “the other” ').
I split and rejoin this with semicolons as part of the prototype’s action code, so there’s a semi-duplicated Attribute ‘tbTags’ which contains them in a manner that’s hopefully more native to Tinderbox.
I created a Stamp which should walk through the list of tags, create a note with the tag name in a ‘/Tags’ note (if it’s not there already), then link the original note to the existing or newly created tag. At one stage, I had this partly working, creating the relevant items in ‘/Tags’ before I swapped it over from being an action to being a rule and adding the tag linking.
Can anyone see what’s (hopefully) obviously wrong?
var tags = $tbTags.split(";");
tags.each(myTag) {
if(!isDuplicateName(myTag)) {
var tagNotes = create("/Tags",myTag);
$Prototype(tagNotes) = "Tag";
}
// find notes to link to
if(!linkedFrom("/Tags/"+myTag)) {
linkFrom("/Tags/"+myTag, "uses tag");
}
}
I’m on 8.9.2. I’ve made pop-up messages about errors appear in the past, but this bit of code isn’t triggering any, which would at least give me something to work on!
As a general guidance, the best way to approach a complex stamp that’s not doing what you want is to break it up into small pieces — pieces too small to possible fail — and then to test each one.
Thanks @mwra and @eastgate - I stripped it right back to the minimum and rebuilt part by part. I know these are sensible practices, but sometimes things seem too obvious to need to apply them
Fair to say there was a bunch of sanity checking I didn’t need to do, and sanity checking I did need to do that I didn’t think I needed to do.
In this rumoured Tinderbox 9, I’d love it were there to be a ‘log()’ function and a message log window. My scrappy debugging style would be enormously grateful.