Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Do notes inherirt $OnAdd from their prototypes? (Read 1587 times)
james a. foster
Full Member
*
Offline



Posts: 130

Do notes inherirt $OnAdd from their prototypes?
Feb 01st, 2017, 7:25pm
 
I am trying to create a note where the $OnAdd is inherited from the note's prototype. That way I can use the protype to set defaults in any note added under another note of that type.

Here is a simple case. Whenever I add a child to a note of type A, I want the child to be of type B. To do that, I set for prototype A $OnAdd equal to "$Prototype=B".

Noiw I create a new note "container", say, with $Prorotype="A".

Now add a note to "container". I would expect it to have prototype A. But it has no protype at all.

Is there a trick? How would I do this?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Do notes inherirt $OnAdd from their prototypes?
Reply #1 - Feb 2nd, 2017, 3:53am
 
$OnAdd does inherit. From your post above the code you quoted has a typo: $Prorotype="A". Try using:

$Prototype="A"

If that isn't the problem, can you post a link to a small file that illustrates the issue as there may be hitherto un-described other factors at play. However, I can confirm, using v6.6.5, that if a prototype note has an $OnAdd set, and note using that prototype will inherit that $OnAdd code.

One other possible factor - you (inadvertently) set a local value for $OnAdd..  If you make 'Container' and edit its $OnOdd and then subsequently set a prototype, $OnAdd will not inherit. Why? Because the edit to $OnAdd made before the prototype was applied sets a local value breaking inheritance—even if the result of the early editing is to leave the value empty. An easy visual way to check if an attribute has a local value is to look at it in the Get Info pop-over, or set the value as a Key Attribute. If an attribute is listed with its name/value shown in bold, it is locally set. If in normal type it is inheriting.

Can you reset inheritance after such a mistake? Yes - see here.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
james a. foster
Full Member
*
Offline



Posts: 130

Re: Do notes inherirt $OnAdd from their prototypes?
Reply #2 - Feb 2nd, 2017, 2:29pm
 
As usual, Thanks Mark! I knew about "local value", where once you change an attribute it is not part of inheritance any more. But I did NOT know that if the attribute is bold then it's local. That's an important, very useful detail.

It would be even better if there were an "islocal()" test.

Speaking of good tips (for others who might read this thread), here is one. These subtle confusions usually happen for me when I'm trying to refine the database: http://www.acrobatfaq.com/atbref6/index/ActionsRules/Optimisingcodeforperform.ht...
Back to top
 
 
  IP Logged
james a. foster
Full Member
*
Offline



Posts: 130

Re: Do notes inherirt $OnAdd from their prototypes?
Reply #3 - Feb 2nd, 2017, 4:40pm
 
Well, I had it working for a second. Now I can't get it to work.  I put the small test file here: http://people.ibest.uidaho.edu/~foster/pub/testing.tbx

Back to top
 
« Last Edit: Feb 2nd, 2017, 4:47pm by james a. foster »  
  IP Logged
james a. foster
Full Member
*
Offline



Posts: 130

Re: Do notes inherirt $OnAdd from their prototypes?
Reply #4 - Feb 2nd, 2017, 4:53pm
 
Well darn. Now it's working again. I took the database I sent you and just deleted and re-entered the value for $OnAdd in the ProtoOutputContainer. Now it works.

I didn't see any difference between what I re-typed and what was there originally. But maybe there is something you will see that I didn't.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Do notes inherirt $OnAdd from their prototypes?
Reply #5 - Feb 2nd, 2017, 6:04pm
 
Took some figuring out but the reason your linked file fails is some unintentional [sic] user error: the opening double-quotes on the action are typographic ('curly') quotes. My hunch is you tried typing some code in a note's $Text then copy/pasted to $OnAdd. My days of 20/20 vision are long gone - I didn't see the “ in the Inspector first time.  Depending on the font “ and " look pretty similar—though they definitely aren't to the app.

I know that sounds dumb. The app should just figure it out, right? Actually, and I'll spare the boring details, it's more complicated to 'guess' than we image as users.

Because people want note text to be familiar (yes, MS Word, we're looking at you) the $Text space of notes now uses all the clever underpinnings you see in Apple Textedit. Type a ' before a word? It knows <g> you meant a ‘ (curly version). If you're typing text it its a nice but trivial thing but for 'code' it does matter.

HTH  Smiley
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
james a. foster
Full Member
*
Offline



Posts: 130

Re: Do notes inherirt $OnAdd from their prototypes?
Reply #6 - Feb 2nd, 2017, 6:24pm
 
Wow. That's subtle. (and I think I've done it before, and you've found it before!),

So then, how does this work with code notes? There I keep complex code in the $Text of a code note, then use a $Rule in the code note to set (let's say) the $OnAdd of another note. In this scenario, the $OnAdd in the second note will ALWAYS hvae the wrong quotes if my code note $Text had anything with quotes (including setting string values)!

Is there a way to tell the $Text to just cut that crap out and use the quotes that *I* want, rather than what *it* wants?
Back to top
 
 
  IP Logged
james a. foster
Full Member
*
Offline



Posts: 130

Re: Do notes inherirt $OnAdd from their prototypes?
Reply #7 - Feb 2nd, 2017, 6:36pm
 
Found a solution! $SmartQuotes determines whether to do this silly straight-to-curly conversion. Set it to false and the problem goes away.

I use a Code prototype for my code notes, so I just set $SmartQuotes=false in the Code prototype and the problem disappeared.

btw...thanks for the description of code nodes in aTBRef. Lovely.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Do notes inherirt $OnAdd from their prototypes?
Reply #8 - Feb 2nd, 2017, 9:56pm
 
Good. IIRC, the v6 version of the build-in 'Code' prototype sets $SmartQuotes for you for code-type notes. If you're using an older doc or copied a prototype from one that extra setting might need to be made by hand. In fact the Code prototype essentially developed out of issue raised by doing 'code notes' in v5.

Anyway, I too find code notes useful for long/complex actions. Now i try to remember to set a code prototype before using a note to write/test code.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print