TableExpression : stamp error

I wanted to automate tables, so I this action in a stamp.
$TableExpression=$Name +" | "+$Modified ;

But what shows up where names of descendants should be is the name of the parent.

Summary tables work just fine – i.e, the table lists the descendants, not the parent – when set up manually (clicking the upper-left icon, etc.).

Why does it do this?

Thanks

Use:

$TableExpression="Name|Modified";

Note that for the expression’s values you use the name of the attribute for each column (‘Modified’) rather than a reference to its value (’$Modified’).

Why do you need the quotations around the expression?

$TableExpression=“Name|Modified”;

rather than the original proposal

$TableExpression=$Name +" | "+$Modified ; (←wrong)

In the second proposal, the action is evaluated when it is applied, and in that context. But a TableExpression should be an expression – a formula.

When assigning expressions, it’s often easiest to put the expression in a known place and simply copy it:

$TableExpression = $TableExpression(/configuration/Sample Table Note)

1 Like

As @eastgate has said, you need to quote the table expression so that $Name and $Modified don’t get evaluated for the parent note’s $Name and $Modified.

However, @mwra’s solution ($TableExpression="Name|Modified") won’t work, because it will return the logical OR of each child’s $Name and $Modified, which will just evaluate to $Name (unless $Name is empty, in which case it will evaluate to $Modified). The problem here is that | is getting interpreted as an expression operator, rather than being embedded in the expression string.

You have to make sure everything is quoted properly. This will work:

$TableExpression='$Name + "|" + $Modified';

Note the single quotes around the expression (necessary if you want to embed double quotes in the string).

Given the fiddliness of nested quotations and Tinderbox’s rather limited support for escaping strings, @eastgate’s solution of keeping the expression in a sample note is a really good one.

True :sob:

I was in a rush, with lots going on on the kitchen I didn’t fully test. @galen’s poijnts are correct and supported. Sorry!

Thank you, mwra, eastgate, and galen,

While I’m digesting all this, would someone point me to documentation for eastgate’s suggestion to just reference a sample expression?

I’m confused. @eastgate’s post doesn’t mention a ‘sample expression’. I’m not sure it woulds necessarily help. A expression in simple one or more executable (evaluate-able) sections of code. This is a single expression:

$Color="blue";

This is a piece of action code containing two discrete expressions:

`$Color=“blue”$Color2=“red”;

What is the task you’re trying to achieve?

I got the term wrong. It should have been “sample note.”

This is what I want documentation for.

Documentation of Tinderbox paths, including specifying attributes of other notes by path is here.

Basically if you have a note named “Sample Table Note”, you can refer to an attribute of that note with the syntax $AttributeName(Sample Table Note). If “Sample Table Note” isn’t a unique name, you can refer to it by its full path instead — for example, if “Sample Table Note” is in the “/configuration” container, you can refer to its attribute values with $AttributeName(/configuration/Sample Table Note).

Here @eastgate is suggesting that you store the table expression you are interested in using in the $TableExpression of such a note, and then refer to that $TableExpression in your stamp. This will allow you to avoid messing around with getting the quotes right in the action code of the stamp.

Here’s an example Tinderbox file that shows you what he means:

stamp example.tbx (56.4 KB)

1 Like

Terrific resource. And thank you for that complete and clear explanation.