Interpolation question

Each case has an edict which collects the text of if its children, each of which have a different prototype.
Case #1 is unwieldy
… so in
Case #2 I capture the outputs of collect_if into separate variables, but I still find it messy
… so next I try to break this into separate lines
Case #3 The variables interpolate, but the string literals disappear.

Why do the literal strings disappear ?

An additional question:

Why the .bold operator affects subsequent text rather than being scoped to the string on which it is called?

Interpolation Question.tbx (99.9 KB)

The construction

$Text =		"Questions".bold + "\n\n" + \
			questions.asString.plain + "\n\n" + \
			"Answers:".bold + "\n\n" + \
			answers.asString.plain + "\n\n" + \
			"Reflections:".bold + "\n\n" + \
			reflections.asString.plain;

depends on \ removing the special meaning of line endings. That works in C, but not in Tinderbox actions.

What I’d do here is define a function so I could write formatText("Questions",questions)+formatText("Answers",answers)

The .bold issue is an error.

Thank you :+1:

How about:

$Text=;
var:list vQuestionList = collect_if(children, $Prototype="Questions", $Text.paragraphList);
var:list vAnswerList = collect_if(children, $Prototype="Answers", $Text.paragraphList);
var:list vReflectionList = collect_if(children, $Prototype="Reflections", $Text.paragraphList);

$Text += "Questions:".bold + "\n\n".plain;
$Text += vQuestionList.format("\n") + "\n\n";
$Text += "Answers:".bold + "\n\n".plain;
$Text += vAnswerList.format("\n") + "\n\n";
$Text += "Reflections:".bold + "\n\n".plain;
$Text += vReflectionList.format("\n");

Notes:

  • Use of .plain to ‘close’ the earlier bolding.
  • By recovering $Text.paragraphList instead of $Text, it enables you to break out the paragraphs within $Text in the report
  • child works here, but I think because Tinderbox guess you mean children. Formally, child means first child (only).

Thank you as well @mwra. I was not familiar with paragraphList. That is handy. I take your point about ‘child’ I’ll ‘fix’ that on my end.

1 Like

These sorts of questions are always useful. I spend ages looking for a (phantom) glitch in list.format() until I realised we were collecting $Text as a singe string. Then the penny dropped about string.paragraphList().