Assign Prototype Based on Name

Is it possible to assign a prototype based on characteristics of the name of the note?
For instance if I have a note with the name “Note - Thoughts on Tinderbox”. How could I detect the first word and then assign the appropriate prototype for notes.

Similarly “Task - Use Tinderbox to research Tinderbox”. Detect ‘Task’ and assign the prototype for tasks.

As well as the ‘code’ to detect the first word I need help with the syntax since there will be a list of prototypes to choose from.

I’m wondering if this would be a compounded “if” conditional statement but I suspect that would get very long winded.

Any help or advice would be greatly appreciated.

I think as v9.5 was presented at last w/e 's meet-up, I can mention this…

Actually, this is coming any day now in v9.5.0. If you type a name like “Use Tinderbox to research Tinderbox#Task” for a new note, Tinderbox will recognise the #-delimited part and if such a prototype doesn’t exist it will make it and add it to /Prototypes in the doc. The new—or pre-existing—“Task” prototype will be applied as the new note’s prototype (i.e. the value of its $Prototype attribute).

For those who use the zip method of touch-typing links to new notes, the same syntax is accepted. Note that the desired prototype’s name is #-appended after the note title (i.e. what becomes $Name).

The syntax will be further described in aTbref 9.5 when Tinderbox v9.5.0 releases.

†. In a case like ‘Task’ where there is a built-in prototype of that name that will be used added. IOW, the chain is: detect a prototype name ▸ is it in the doc? ▸ Yes—apply it as $Prototype ▸ No, but it is available from unused built-in prototypes—add it and apply it as $Prototype ▸ No, and not available from unused built-in prototypes—add a new prototype and apply it as $Prototype. In the latter case, if the doc has no /Prototypes container, that will be added and then the new prototype be placed in it.

1 Like

You could also use an agent that looks for a pattern in the note name

Query: $Name.beginsWith("Note - ")
Action: $Prototype="Note"; 

But the new brainstorming technique, to be introduced in Tinderbox 9.5, is probably what you want.

As always I’m indebted for your help.

The 9.5 solution will be much easier than I anticipated.


I’d given half a thought to an agent but didn’t see how to make it work effectively until I saw your syntax.

when do we get 9.5?


Soon - as soon as the beta testers stop breaking it. :rofl: (disclaimer: I’m one of them). Frustratingly for all the significant improvements in previewing and image handling that folk have (obliquely) asked for have collided with increasing macOS security restrictions to create a tough circle to square for the developer. In part we have to recognise that the suggested way of showing HTML (webpage) internal content that uses files outside the app can allow for badness if not handled with care. We rush to say, “I’ll never have that problem” but the design is now forced to allow for it.

So, a lot of unseen work going on to avoid surprises on public release. :slight_smile:

If you want to go the agent route (there’s never just one way!) and wanted to lose the 'Note - " hint from the begining of the note $Name, we can tweak the Action a bit:

Query: $Name.beginsWith("Note - ")
Action: $Prototype="Note";$Name = $Name.substr(7);

What’s the last bit? Well we wisg to dump the "Note - " prefix which is 8 characters long. The String.substr() operator. If given just one argument (input) number N, the operator returns the source string but starting N characters in. The N is zero based to the eighth place is 7 and thus the code.

But as noted above the new built-in method is a zero configuration method - it even makes the prototype for you, puts it in the right place and assigns it to the new note for the effort of adding a # marker in the initial naming. Still, it’s always nice to have choice.