Tinderbox Forum

Adding Text with a Stamp?

Can I use a stamp that will add to the Text already in the Text of the Note without deleting the existing text? If so, how?



Yes. This is simply done. Stamp code:

$Text = $Text + "Some text.";

Basically the pattern is: attribute = existing value + additional data.

In the first example. If your $Text was “Hello world.”, the stamp would result in “Hello world.Some text.”. Note the run on. So you might need to start your additional data with a space, i.e. " Some text.". More practical is to insert a line break between existing and new $Text. This is done using the code \n, like so:

$Text = $Text + "\n" + "Some text.";

or more succinctly as:

$Text = $Text + "\nSome text.";

Also, to add a Tab character, use \t.

1 Like

Brilliant. I’ve also been using the export to Excel lesson you gave me. Working very nicely!


1 Like

Can I do the same to add text to the $Name attribute?

You can use similar actions to add text to $Name or any string attribute.

So, in very practical terms. If the title ($Name of the note) is ‘A’ and we want to add the string “, about B”, the stamp would be:

$name = $Name + ", about B";

As @eastgate notes, $Name is a String-type attribute so at code level you are adding a literal string to another string. Perhaps you want the string to pull text from elsewhere:

$Name = $Name + ": [Project: " + $Project(parent);

If note is ‘A’ and the parent’s $Project value is “X” the result of the above is “A: Project X”.

1 Like

This thread is very topical for me. I want to add a separator line between lines of text and currently I use:

$Text = $Text + "\n" + "_" *75 + "\n"

This works well when I want the line to be at the bottom of the text field but sometimes I want to add a separator line where my cursor currently is.

Any suggestions on how I could do that?

As we are mixing concatenation (’+’ with texts) and maths (*), and though this stamp works fine, as a rule of thumb this might be a safer general approach:

$Text = $Text + "\n" + ("_" *75) + "\n";

The parentheses ensure the long 75-character string is created before it is ‘aded’ to the preceding string.

As to ‘inserting at cursor’ with a stamp, you can’t do that via action code in the sense described because action code has no way to access the insertion point. But, we can type a marker and replace that. So at your insertion point type ##### (5 hash) symbols). Now we use this stamp:

var vDashes("_"*75);
$Text = $Text.replace("#####", vDashes);

We fist use a variable to hold the 75 underscores, as it’s not ideal to do the matches part inside the .replace() input. Then we find and replace the hashes with our ‘ruler’ which is stored in the variable. Of course, if your text already includes runs of 5 hashes (or more you will need to choose another marker that will be unique within the overall $Text and put the same marker string into the above stamp.

Checked in v8.9.2 on macOS 10.14.6.

†. The BrE # ‘hash’ is ‘pound’ in AmE. In BrE ‘pound’ is £. :slight_smile:

1 Like

For our general funds of information, What is the BrE conventional shorthand for weight? One might expect butchers, grocers, chandlers and such to tire of writing “18 lb.”

Well, we’re all metric now. But Imperial measures live on in all sort of ways, especially in recipes and many things especially ingredients that need to be weighted, e.g. for baking. I think doorstep milk bottles may still be pints, but beer is the main holdout by being in sold in pints (though bottled canned is metric = luckily 0.5l ≈ pt. Pounds & ounces: lb & oz, I’m not aware of (common) shorter valiants.

Cooking is fun as we don’t use AmE ‘cups’ and we both use fl. oz., but different in volume ( as are UK/Us pints (pt) and gallons (g or gl) though both have the same number of each.

Weight of people. I’m guessing those their 40s might be the cut-off. Those younger with use kg for weight. Those of us pre-decimalisation use Stones (st.) and Pounds (lb.): a stone is 14 pounds.

Height of people: Those younger with use cm for height. Old will likely use height in ft (’) and inches (’)—there are actually discrete unicode symbols for these symbols.

Measurement is both metric and imperial, especially in the building trade (old buildings!), though most cars are now all metric.

We buy petrol (gas AmE) to put in our cars (autos AmE) and lorries (trucks AmE) in litres (liters AmE) but measure distance in miles, including all roadsigns (bi-lingual in Wales). Tyres (tires AmE) are inflated in either psi or Bars though most pumps offer either (again generation differences in usage).

Money, pounds (£) pence (p.) is decimal, but art, racing horses and a few other goods are sold in Guineas (gn. or gns., which is 21 shillings, thus £105 in ‘new money’).

I think that covers the basics. TGIF, soon time for a pint (c.500 ml). :slight_smile:


But you left out the slug, or geepound! Basic physics (I think).


Mark, Thanks for the help. I tried your suggestion and it works beautifully.

As an aside, I grew up in Canada during the change over to metric and then moved to Australia, where the metric changeover happened at a similar time, and I think Australia managed the changeover a bit better. Canada has the handicap of a huge neighbour that continues to use the Imperial system and the spillover seems to be unavoidable. In any case, each country whether its Canada, Australia or Britain seems to have it’s own idiosyncratic mix of old and new measurement standards. It’s interesting to see the differences.

1 Like