Changing Name of Reference-Prototype Notes

Dear all,

I would like to modify the name of the notes that are created with the Reference prototype when I drag (with command+option) Bookends entries into Tinderbox. The standard name for those notes is the title of the reference — book, article, etc. — but I would like it to be first author publication date (e.g., Smith 2020). However:

  1. I cannot find an attribute for the first author; am I missing something? If not, would anyone have any suggestions on how to achieve what I am trying to do?
  2. Do you think it would be better to change the name of those notes with a rule, an edict, a stamp? I only need to change the name of the note once, when I drag the reference from Bookend, so I thought a stamp would do. Besides, I though a rule or an edict would be overwritten — in this case deleted — whenever I install a new version of Tinderbox, given that the Reference prototype comes pre-installed with Tinderbox. But maybe this is a wrong assumption.

As usual, thank you for your consideration.

Best regards,
Enrico

When a reference is imported from Bookends, all the author(s) names are put in $Authors. to get the first author, call $Authors.at(0). The .at() operator enumerates list items from zero, meaning that first item is zero (.at(0)) and not one (.at(1))—the latter calling the second list item, and so on. note too, that the parameter is a number 0 and not a quoted string "0".

Thus the action you need is:

$Name = $Authors.at(0) + " " + $PublicationYear;

Depending on the way the source data is formatted, we might get “Smith”, “John Q. Smith” or “Smith, John Q.”. The code above works fine for the first example, but here are codes for the author last name other two layouts.

Last name last: $Authors.at(0).split(" ").at(-1). Take the first author from the list, split the string on spaces and return the last list item. For a name like Ursula von der Leyen, you may have to do some manual adjustment as rules for storing last names with multiple discrete words tends to vary.

Last name first: $Authors.at(0).split(",").at(0). In this multi-word last name are not a problem as the last name is everything before the first comma. Or, should be. This copes with ‘von der Leyen, Ursula’. But, you may see formatting like ‘Leyen, von der, Ursula’ or ‘Leyen, Ursula, von der’, so again some triage may be needed.

Despite all the complexity of listing multi-word last names or the Spanish/Portuguese method of using matronymic and patronymic last names (in vary order and either one/both), essential you may need to hand adjust the $Name to match the source formatted reference (remember to disable that note’s $Rule or you manual edit will be removed next time the rule runs.

As setting the $Name is something you need to set once, having a $Rule re-set it several times a minute seems a waste of effort (and CPU as the reference note build in number). The operator isn’t useful as a check here, so I’d go for an $Edict as it runs only about once an hour or on (manual) demand.

I hope that helps. :slight_smile:

If you want to make your own version of the Reference prototype, see here:

1 Like

The name of the note that is created in Tinderbox will vary according to the reference format that is selected in Bookends. I created my own custom format for export to Tinderbox, and I switch to that in Bookends before I drag and drop the reference into Tinderbox. Sometimes I forget, and get a name in Harvard or APA, which causes a little cursing and a second drag and drop!

1 Like

Thank you very much, @mwra, @PaulWalters, and @MartinBoycott-Brown, for your precious help.

I modified @mwra’s action to:

$Name = $Authors.at(0).split(",").at(0) + " " + $PublicationYear.split(" ").at(0);

because sometimes Bookends’ Date field contains month and day, in addition to the year. By the way, could you please point me to the pages of aTbRef8 where the .at( ) and the .split( ) operators are discussed? I wanted to learn more, but I could not locate them — on an unrelated note, does the aTbRef8 exist as a downloadable Tinderbox file?

The action above works as an edict and as a stamp on existing Reference notes created by dragging (with command+option) Bookends entries. However, I ran into a problem when trying to create a new MyReference prototype or modify the existing Reference prototype by adding the action above as an edict: because the edict is supposed to change the name of the note according to the values of the $Authors and $PublicationYear attributes, in the absence of those values, the name of the new or modified prototype will be blank… The new or modified prototype is there, and it does work:

Screen Shot 2020-12-10 at 2.58.19 PM

Only, it’s easy to overlook. Would you have any suggestions? Thank you for your consideration.

Best regards,
Enrico

It is much easier to set things up at the Bookends side of things. From the user manual, p. 212:

“Use year-only for Date. If the Format has the Use year-only for Date button checked and the field order includes a ‘d’ (date), Bookends will look in the Date field for a year. If it finds one, it will output the year rather than the entire contents of the Date field. A year is defined as a four digit number beginning with a ‘1’ or a ‘2’. If Use year-only for Date is unchecked, the entire Date field is output. Note that placing a comma at the end of the Date field will cause Bookends to output it without parsing. This is useful, for example, if you have checked Use year-only for Date but for an occasional reference you want a complex date (e.g. the year originally published and the year reprinted) output as entered.”

So my custom format for drag and drop has the field order in Bookends set as a d t (which gives author date title).

All action code operators as listed and described at A Tinderbox Reference File → Actions & Rules → Operators → Full Operator List. Specifically, .at() (used with lists: Set and List data types) and .split() (used with String, and string-based data types).

Key lists, like those for system attributes, operators (q.v.), export code, date formats and designators are easily found via a set of quick access links at the top of every page in aTbRef.

Yes, it has been since first created back in 2005! See Obtaining the aTbRef source TBX file.

As you’ve noticed, the format in which the author names are brought into Tinderbox depends on your settings in Bookends. Fix the latter and you should find it you may have less work to do at the Tinderbox end. The same applies to ‘Year’ information, you can configure it in your Bookends format settings. The settings are deep but complex: it took me some time to figure it, but I’ve found both Bookends’ user forum and the developer to be responsive and helpful.

‘Reference’ Prototype
The ‘Reference’ prototype is the only one used by Bookends reference import. If you rename it Tinderbox will likely make a new copy of the built-in one so you are better to edit the existing prototype unless you want to act on the reference notes after import. But do remember a note can only have one prototype, though there are other approaches such as an agent looking for un-renamed notes.

So your edict/stamp code has a problem if there is no author or year data? Firstly, disable the edict in the prototype (see the Edict Inspector)—see the ‘enabled’ tick-box bottom left. The attribute saving this state does not inherit, deliberately so, for just this reason. Often you want rules or edicts to run in notes using a prototype but not in the prototype itself.

In a more general setting you could guard against bad references with missing author or year, as follows. Check for $Authors data, and if none, take no action. If authors are found process that and then check for the year and leave that out if wrong. Thus you get in order: no rename, just the author, or author and year. So (with line breaks and indenting for clarity:

if($Authors){
  $Name = $Authors.at(0).split(",").at(0);
  if($PublicationYear){
    $Name = $Name + " " + $PublicationYear.split(" ").at(0);
  }
};

Thank you, @MartinBoycott-Brown, for following up on that. I double-checked, and all the formats I use in Bookends — I publish in a relatively small number of journals — already have the “Use year-only for date” checkbox ticked, so I don’t think I will need a special Bookends format or the .split(" ").at(0) after $PublicationYear in the Tinderbox action. Thank you again.

Best regards,
Enrico

Thank you, @mwra, for the links to the page with the downloadable aTbRef8 Tinderbox file and to the pages with the explanations of those operators. I had gone through the full operator list multiple times, but because I was looking for .at( ) and .split( ) operators, instead of List/Set.at(N) and String.split("pattern"), I ended up missed them, so thank you for pointing me in the right direction.

Thank you also for all the different solutions to the problem of the “no-name” reference prototype!

As for the settings of the formats manager in Bookends, I confirm what I wrote to @MartinBoycott-Brown above: the formats I usually use all have the the “Use year-only for date” checkbox ticked; however, after further testing, if I drag references with the Science format, which has the “Use year-only for date” checkbox ticked, I still get month and day in addition to the year in Tinderbox, unless I use the .split(" ").at(0) after $PublicationYear in the Tinderbox action. Do you think that is an issue on the Bookends side?

Again, thank you for your help.

Best regards,
Enrico

I just tried a test and it works as expected for me. That is, a drag and drop using the Science format gives me a note in Tinderbox which has only the year in the name of the note, while the attribute $PublicationYear has the full date (year-day-month in the example I tried). Do your dates have a comma or other punctuation at the end of the field?

I did this for two reasons. First, it indicates the data type the operator works on and secondly because some dot operators work differently depending on the type of data worked upon. For instance .format() has different effects for string vs. date vs. list vs. number, etc. .contains() has different and more restrictive inputs when working on a list as opposed to a string.

For the same reason, I use generic names like $MySet or $MyNumber to help indicate the data types of operator input or output. The generic use of a ‘My-’ prefix on such examples goes way back in Tinderbox forum use, before they also got adopted by Tinderbox v6.0 as the ‘Sandbox’ group of system attributes. Despite the latter, I think it helpful to continue using the names not least because it helps of copy pasting code into a test document - you’ve fewer (or no) new attributes to add before using the code.

Re Bookends formats, though the syntax/markup of formats makes Tinderbox action code look simple, do persist or ask in the Bookends forums for help. Much like Tinderbox action code and export templates, once written you generally won’t need to touch it again during a project.

Where I’ve changed a Bookends built-in format, I generally duplicate it first so app updates don’t conflict with/over-write my changes, plus I have several variants of some, e.g. full BibTeX record vs. BibTeX with just name and ‘key’ for copy paste of keys into LaTex \cite{}, which led to making LaTeX ‘\cite{key}’ type formats for even easier copy/paste.

Thank you for the clarification, @mwra. Just to make sure, though — it’s difficult to convey intention in a forum — I was not complaining about the fact that those operators were not where I expected them to be: they are where they should be; if only I had used a simple command+F search, instead of insisting in scrolling through the list late at night — I would have found them…

Thank you, @MartinBoycott-Brown, for taking the time to test that. Just to make sure I am doing the same things you’re doing.

  1. In Bookends 13.4.8, I select the Science format, which has the “Use year-only for date” checkbox ticked:

  1. I choose a reference that has year, month, and day (without any punctuation after the day) in the Date field, but whose citation in Science format only displays the year:

  1. In Tinderbox 8.9.0 (b485), I modify the built-in Reference prototype by adding — but disabling — the edict:

  1. I drag (with option+command) the reference from Bookends to Tinderbox, only to get the following:

Does that corresponds to what you’re doing? Thank you for your consideration.

Salve Enrico.

Almost everything is the same, except that I use the built-in Reference prototype in Tinderbox, which has never been altered.

I do not use the Science format myself, so I have only activated it in Bookends for the purposes of testing, and it is completely unaltered from standard. I have just tested again and I get a note in Tinderbox with year only in the name of the note. I surmise that there is something in your setup that is causing the different behaviour.

Best of luck!

Sorry - no censure was intended. I simply meant to imply the key references sit in a standard place in the overall site. Of course, that only helps more once you know where those paces are. I’m trying to come up with a better solution! :slight_smile:

Also note the TBX file contains instructions on how to create a local HTML copy of the aTbRef site, though the TBX offers better search capability.

I get the same as @MartinBoycott-Brown, after enabling the ‘science’ format in Bookends v13.4.8.

I checked and my (default) ‘Science’ format looks the same as yours illustrated above.

Here is my test file: ref-import-test.tbx (79.4 KB)

And just for clarity, I should state that there is no edict in my prototype. It is completely as provided by Tinderbox, with no alteration.

Thank you, @mwra and @MartinBoycott-Brown, for your patience and persistence.

Unfortunately, I cannot reproduce what @MartinBoycott-Brown observes. If I simply drag (with option+command) a reference in the Science format from Bookends to a brand new Tinderbox document — with the unmodified built-in Reference prototype — I don’t get a note with the year — in whatever format — in the name of the note: I get a note with the title of the reference in the name of the note.

But I can replicate what @mwra observed, which is different from what @MartinBoycott-Brown did and is what instead I was already doing since post no. 4:

The reason the edict in post no. 14 did not contain the operator .split(" ").at(0); after the $PublicationYear is because I had misunderstood that if I selected a reference format in Bookends that only displays the year, and not the month and day — such as, for example, the Science format — I would not need the operator .split(" ").at(0); after the $PublicationYear in the edict. I was clearly mistaken because in post no. 17 @mwra used precisely that operator in the edict with the Science format.

In conclusion, with the — disabled — edict $Name = $Authors.at(0).split(",").at(0) + " " + $PublicationYear.split(" ").at(0); in the built-in Reference prototype I can achieve what I wished to do, so thank you very much for all your help. My apologies for my misunderstanding, which dragged on this post longer than it needed to be and wasted your time and energy.

Best regards,
Enrico

1 Like

For clarity—and for reasons I don’t understand—you must press Cmd+Opt before starting the drag in Bookends or you get a different result in Tinderbox that doesn’t trigger application of the Tinderbox ‘Reference’ prototype.

Why on earth the macOS code designers thought it helpful to allow this difference (modifiers pressed before vs. pressed during), heavens only knows!