Note $Text template

Hi everyone.
How can I create a note $Text template? I want to edit a prototype’s $Text with literal text, along with placeholders for attributes. The result I’m aiming for is a predefined note, which has a standard format to display information.
I understand this could be done with HTML export, but first - links don’t work in preview mode; and second - I want to use the power of TBX to create links, without having to learn how the HTML export works.
Thank you all

Your requirement is not clear. What is your concept of a “predefined” note? E.g., the formatting / templating you want to achieve. How attributes figure into what you want to do in the note $Text, etc.

It would be helpful if you could post a small example file — even if it isn’t working the way you want. Or a mock-up of what you imagine the result should be.

Hi Paul, thanks for replying.
I have notes for songs, which I want them all to work the same way. So the $Text of all those notes should be like this:

Snog name (automatically rendered from $Name, and link to the corresponded album taken from $Album)
Artist (automatically from $ArtistName)
Lyrics by (automatically from $WriterName)

song lyrics (manually paste by me)

You can’t set a default $Text for prototype which is applied once, when the prototype is first set, or the note using that prototype is created. You can’t create notes in $Text via action code (re SongName). You can’t create prototype-derived $text which has one-off action code substitutions. But… you could use an edict.

Assumptions:

  • $Album, $ArtistName and $WriterName are all already set for the note.
  • $Album is a unique note name in the document and that note occurs before any aliases of said note.

Then an edict (or stamp) could run this code:

if($Text==""){
   $Text = "Song name: " + $Name + "\n";
   $Text = $Text + "Artist: " + $ArtistName + "\n";
   $Text = $Text + "Lyrics by: " + $WriterName + "\n\n";
   linkToOriginal($Album);
}

Note that the action code can’t set RTF styles, e.g. bolding the captions at the beginning of the lines.

Thanks, Mark,
two questions:

  1. can the edict make the $Name as a text link to the album note based on the $Album attribute of the song?
  2. when I use the built-in HTML template with notes that I already have made text links in them (or other links) do present links in preview mode, but when clicked nothing happens. Can those links work in preview mode?
    This last option might be the solution to my challenge.

#1. No as previously explained, action code (stamp, edict, whatever) can’t style $Text, including making in_$Text (text) links. It can make note-to-note (basic) links - as in my code above. Text links need to be created manually by the author.

#2. The preview is designed to preview the output in HTML rendered form, rather than an alternative way to navigate the document. However, I believe that if the target note has a suitable template (i.e. that renders in preview) then links should work. I believe you may needed to have first exported the document to HTML at least once - if still confused on this aspect I’d email tech support directly (bearing in mind we’re fellow users here, so we can’t see ‘under the hood’).

I hope that helps…

1 Like

Thanks so much, Mark.
I will try that.

1 Like

Better still:

if($Text==“”) {$Text=$Text(/path/to/generic/Song);}

This will copy the text of some other note to your empty song. This might be an edict, but in some workflows an OnAdd action or a Stamp might be even better.

Another possibility is to use a TextExpander macro to expand the boilerplate text. TextExpander is currently among the 18 terrific tools on sale at our Artisanal Software Festival: http://www.artisanalSoftwareFestival.com/

But, how does that generic text add (as requested) the current note’s $Name, $ArtistName and $WriterName?

Thanks, @eastgate,
but like @mwra said, this dose does not give the functionality I’m looking for.