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
Add Key Attributes via OnAdd Action (Read 6707 times)
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Add Key Attributes via OnAdd Action
Mar 08th, 2011, 2:25pm
 
How do you create an OnAdd Action to define certain key attributes for notes in a container note? I know this should be simple, but I can't work it out. All I want to do is add the key attributes Source and Page to the notes as they are created. I have Source and Page defined as attributes in the User list.

Logic tells me this can be achieved by creating the OnAdd Action KeyAttributes=Source;Page in the OnAdd Action field of the container's Rename window, but doing this has no effect beyond removing "none" from the Key Attributes: field in the note's sidebar.

Other OnAdd Actions are working okay.

What obvous thing am I missing?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add Key Attributes via OnAdd Action
Reply #1 - Mar 8th, 2011, 3:03pm
 
OnAdd action:

  $KeyAttributes="Source;Page"

Breakdown:
  • We're setting the added note's Key Attributes, so $KeyAttributes is the left side.
  • $KeyAttributes is a Set-type attribute. A set's value is a string composed of one or more semicolon-delimited values.
  • The values are the names of the attributes to list, so we use just the attribute's name with no $ prefix ($ prefixes are used as a reference to the attribut'es value).
  • A set uses a string to hold its data and in code we delimit string literals with quotes, either single or double, but double is the normal default choice.
Thus

  $KeyAttributes="Source;Page"

Only one key attribute? Use:

  $KeyAttributes="Source"

More than two? Use:

  $KeyAttributes="Source;Page;FullName"

...and so on.
Back to top
 
« Last Edit: Mar 9th, 2011, 11:37am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Re: Add Key Attributes via OnAdd Action
Reply #2 - Mar 9th, 2011, 10:25am
 
Perfect! Many thanks, Mark - and for such a rapid response. I obviously need to delve much deeper into attribute types, delimiters, etc. I mostly use TBX for complex mapping, and haven't needed to do much of this. It's where the learning curve really starts...

Actually, the Help documents and material on the site are a bit intimidating to anyone starting down this road, I think. A fair amount of unexplained terminology, and answers to specific issues are not always easy to find - as in this rather simple case. It would be great if there was a simple manual outlining how to get to grips with deeper TBX use. Though the asking is easy, of course - someone would have to write it...
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add Key Attributes via OnAdd Action
Reply #3 - Mar 9th, 2011, 11:35am
 
The trouble with 'simple' is it is often only so in the eye of the beholder. We all have a tendency to assume our starting point is the same as everyone else's; experience argues otherwise. Anyway, what sorts of issues or concepts are unexplained? From a helpers perspective it's sometimes hard to figure what people don't know - or rather - come at an issue from a totally different perspective. Happy to try and help if a few unknown unknowns are made known unknowns.
Back to top
 
« Last Edit: Mar 9th, 2011, 11:39am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Re: Add Key Attributes via OnAdd Action
Reply #4 - Mar 9th, 2011, 12:54pm
 
Well, an example would be my query here. I wanted to do something very simple, but was stumped to find anything to help me in the Help pages or elsewhere. The help pages/User's Manual are excellent on basic usage: Basics, Notes, Attributes, etc - all those sections. I have used simple ActOn Action formulae for a long time with no problem - Color=red (sans the $), for example. But when I wanted to do something a little more complex, there was nothing to tell me accessibly, for example, that I needed to use an $ symbol or quotes and why.

There's a large leap in the User's Manual from the initial pages to the Appendices. The complex stuff is in the latter, but arriving there from the initial pages is like suddenly being catapulted through several orders of complexity and technical knowhow. You end up trawling through them in some desperation in the hope you'll find something that looks more or less like what you need, wondering why you need to graduate through all this to learn that you need to put quotes round a term - at least, you do if you have no coding experience. In fact, I have found nothing that does explain why I need those quotes in this situation. And while most of the examples in the first pages include the $ prefix (without explanation) in fact my usages have always worked fine without it. So it all ends up looking rather mystifying. As a result, I usually end up just creating prototypes, and everything is fine - until you reach a point where this isn't appropriate, or just want to learn how to do things more granularly.

I'm grateful for your breakdown in the answer to my query, but confess I find it hard to grasp. For example, "$ prefixes are used as a reference to the attribute's value" is comprehensible in itself, but I don't understand its application in this context. The last point - "A set uses a string to hold its data and in code we delimit string literals with quotes, either single or double, but double is the normal default choice" - I fear makes very little sense to me as someone with no coding experience.

I don't think I can be alone here. I love TBX and value it enormously. I use it all the time as a fundamental part of my workflow and recommend it constantly. For most of what I do with it, I don't need this degree of technical understanding of how its deeper features work. But when I do, I am left somewhat high and dry by the lack of basic (intermediate?) orientation - perhaps a simple glossary - as to what many of these terms mean and how to get to what I need. With luck I can prise some of it out of the Appendices, but it certainly ain't easy...

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add Key Attributes via OnAdd Action
Reply #5 - Mar 9th, 2011, 2:34pm
 
The task is only simple if you know what to do - in this case understand a bit about TB action code. Without that the user simply won't understand any help regardless of the task.

"Name" vs $Name. The first is simply a bit of text with the letters N-a-m-e. The second is a way of saying "use the value of an attribute whose same is Name". So? Well, consider a note called "Malcolm" with a String-type (text) attribute called MyString. Let's see what happens when we apply each of the two preceding values in a rule.

Rule:  $MyString = "Name"   --> value of Name

Rule:  $MyString = $Name   --> value of Malcolm

Rule:  $MyString = "$Name"   --> value of $Name

Rule:  $MyString = Name   --> value is probably Malcolm BAD - Don't use this form

The last is problematic as TB left to guess where you meant the literal test 'Name' or the values of attribute 'Name'. It was the original syntax (and still works, if you must) but I believe it is very unintuitive for a learner, which is why it's been updated so we use a $ in front of an attribute name to tell TB when we're referring to an attribute. Indeed that's why you'll see people referring in general posts to things like $People, to indicate they're talking about an attribute name.

Anyway, I'm sorry to bring up the last form, but it's out there, you can trip over it by mistake and it's often used in old examples in the forum, wiki, etc. My advice to a non-tech user like yourself - avoid it.

So, back to the first 3 examples. Do you see why you get different values as a result?  I'll check this makes sense before moving on.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Re: Add Key Attributes via OnAdd Action
Reply #6 - Mar 10th, 2011, 12:31pm
 
Hi Mark -

Many thanks again, and apologies for the late reply - force majeure, I'm afraid. I very much appreciate the time you're taking on this.

Yes, I get it. Clear as light once explained, and much what I had worked out after pondering. The $ prefix refers TB to the attribute itself, quotes to the literal text string (even if it has the $ prefix, which now reverts to being literal text itself). I've played around with this and variations and it's all crystal clear. As you say, the non-prefixed form does work, at least as I've been using it, but I get the point that this is basically luck, in the sense that the option is still in the coding but is insecure.

It'd be great if something like this explanation could be included higher up in the User's Manual, in the main pages, perhaps as part of a beginner's guide to the main syntax TB uses. It's fairly basic knowledge but is rather hidden in the Appendices, where much greater technical know-how seems to be assumed than in the main pages, making it hard to winnow out.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add Key Attributes via OnAdd Action
Reply #7 - Mar 10th, 2011, 3:46pm
 
In the meantime check out my aTbRef, especially the section on deprecation and the section on Objects & Concepts.
Back to top
 
« Last Edit: Mar 10th, 2011, 4:27pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Re: Add Key Attributes via OnAdd Action
Reply #8 - Mar 10th, 2011, 4:14pm
 
But this is excellent - lucid, pithy, immediately understandable! Why isn't it in the Help menu? I've used TB for a couple of years now, have surfed the Wiki now and again, but have never found this! My own dumbness, perhaps, but this should be easily to hand!
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Add Key Attributes via OnAdd Action
Reply #9 - Mar 10th, 2011, 4:33pm
 
Thanks for the kind words. Basically, it started out as my attempt to understand TB. Then I figured out HTML export and so it seemed churlish not to put it on the web and share. I think the explanation on string vs attribute will probably find a home there somewhere too. However, like the problem with legacy code forms, aTbRef has got a bit gnarly. As there are so many inbound web links from here and the wiki I try not to restructure the doc too often or they'd all break.

I'm sure your observations re the Help will get taken on board.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Malcolm Coad
Full Member
*
Offline



Posts: 25
Santiago, Chile
Re: Add Key Attributes via OnAdd Action
Reply #10 - Mar 10th, 2011, 4:42pm
 
I hope so! It reads just like that, as by someone who has grappled with the problems and pithily summarised the issues and solutions. And "gnarly" is a good word. There's a lot of excellent material out there, in the Wiki and the Cook Book, as well as this, and the Help pages, of course, and Mark Bernstein's book. But it's all got a bit baroque and multi-branched, and hard to negotiate, which can be very frustrating of you need a rapid answer to a particular problem.
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print