Tinderbox Forum

Apply a prototype to a note created with create

If you use to create to generate a new note, what would be the easiest way to designate which prototype you want to be associated to this note. I could think of a number of conditional arguments, but I’m wondering if there is a simple way to apply a prototype parameter along with create.

Re use the path./name used to create it.

create("/hardware/taps"); 
$Prototype("/hardware/taps") = "pEvent"; 

Of course the path could be a variable. Perhaps the jump here is that offset attribute offset references can be used on the left side of the expression as well as on the right side.

See more in Left side expressions.

1 Like

Amazing. Works like a charm. Learned something new. :slight_smile:

var vName("Product Construct"+" ["+$Project+"]");
if($RequiresCustomization==true){
   create($Path,vName)
};
$Prototype($Path/vName)="pProductConstruct";

For those interested, what I’m doing is working on creating a method for conditional templates. The var above lets me set the name of the note that will be created and nested under a project note. This note will get a unique name based on the project (I may add other elements down the road to improve uniqueness…the incremental formalization will emerge).

I think check if this particular project requires customization, if it does then this “extra” note is created and added to the project. Note, I’m using this code in a Stamp, as I only want it generated once. I may come up with an OnAdd application later, not sure yet.

1 Like