I see…yes I played around with that before. Passing attributes around like that might work in different contexts, but so far I’ve not be able to get it to work directly like you’re trying. It creates some kind of circular reference. I wanted to have a different attribute as a drop do that I could use to swap the attributes used for a note. I ultimately landed on the idea that I’d just display the prototype attribute and swap prototypes this way.
Another way you might try is to run a collect to get all the names of the prototype and to populate the $AssingPrototypes, e.g. $AssignPrototypes=collect(children,"Prototypes");. You could then have some action that would they for through the steps to assign the prototype name. But again, if you’re just looking for a display attribute to assign the prototype, the most direct approach is to do what I show above.
Thanks Michael - that’s what I tried - to have one prototype for my folders and be able to add a second prototype that will be assigned to all childs of this folder with the OnAdd method. “pPerson” is the name of the prototype I would like to assign to all children of this folder…
where this is bound to the newly-added note. But that’s not what you want! You want to set $Prototype(this) to $AssignPrototype("Personen") – the note with the OnAdd rule.
The OnAdd rule is run when a note is added to a container, so what you want is:
So, if I’m understanding you right, what you want is this, your parent, e.g. “Personen Folder”, to have one assigned prototype, e.g. “pFolder” and you want the children of this folder to have a different prototype, e.g. “Person”. In this case, you’d simply point your $OnAdd to the pPerson prototype like this, $Prototype="Person";. This is exactly what we covered in yestrday’s meetup: Meetup 18SEPT21 Lesson 1: Blogging [Basic] with Tinderbox - Setting the foundation.
yes and no
I want a prototype for all my folders (“pFolder”) but the children of different folders should become an individual prototype while still using the same prototype for the folder.
For example: I have one folder called “people” and one called “cultural studies”. Both will get the prototype “pFolder” and so the OnAdd attribute $Prototype=$AssignPrototype(parent);
For the folder called “people” the attribute AssignPrototype will get the value “pPeople” and for the folder called “cultural studies” the attribute AssignPrototype will get the value “pArticle”.
So I can maintain one prototype for all folders and still have an individual OnAdd action depending on the value I put into the attribute AssignPrototype.
How can I retrieve the value of an attribute of a specific note with $name=“gPrototype” in my OnAdd action?
First, if I know there’s a top-level notes name gPrototype, I can get its value easily:
$MyString(/gPrototype)
If I know where to find gPrototype, that’s easy too. Suppose I know the gPrototype is in a container “Fancy Prototypes”. I can refer to this note through its path down the hierarchy.
$MyString(/Fancy Prototypes/gPrototype)
Finally — this is gilding the lilly! – suppose we want to get the values of this attribute for every notes names gPrototype in a document where lots of notes have this name. (Don’t do this if you don’t need to!). The expression find($Name=="gPrototype) returns a list of the paths that satisfy this condition — the notes that are named “gPrototype”. So
$MyString( find($Name=="gPrototype") )
returns a list of values, one for each note named “gPrototype”.
something is going wrong… I understood the concept using the designators (I think).
But still struggle with the syntax. The name of the note I reference is “gPreferences”. The path attribute shows “/gPreferences”. The attribute of this note I try to fetch is “gPersonProto”.
What is going wrong? Can you share a screen shot? When I tried doing something similar I got caught in some kind of circular reference and the prototype will always end up becoming “None” no matter what I tried.
Actually, I had not. Sorry, missed that. I just tried it and it is working perfectly for me. I love it, actually, and and am going to start using this immediately in my files. WONDERFUL idea. I clearly was not understand you earlier, sorry about that.
I tried to get an attribute from a note by the name of the note. Didn’t work. And the preview is strange - the values for (A) and (C) should be the same - they are not:
Sorry, I don’t understand. Are you trying to pull in the value from the attribute JustATest into the $Text of the note?
If so, you’d say this: ^value($JustATest)^, to get the value from this note.
To get the value from another note you’d say ^value($JustATest("OtherNote'sName")^' or ^value($JustATest(/thepath/OtherNote’sName)^’. You need to be sure to use straight quotes.
the output in the preview is just for debugging.
What I try to solve is simple: get the value of an attribute of a note where I address the note with the path to the note:
$gPersonProto(/gPreferences);
(“gPersonProto” is the attribute I try to access, “gPreferences” is the name of the note)
I tried to write the value I got this way into an attribute of the folder.
P.S.: ^value($gPersonProto(/gPreferences)^ returns nothing too in preview