PadCodedocs

Text with values

Mix words and values in text with braces, like Hello, {name}. Formulas work inside the braces too.

Put a variable's name in braces inside text, and the text shows its value: Hello, {name}! shows Hello, Ada! when name is Ada. The braces can hold any formula, like {count * 2} or {currency(total)}, so one line of text can mix words, numbers and dates.

A Text whose Content is “Coffees today: {count}”; the canvas shows Coffees today: 0.

#Write text with values

  1. Select a view with words in it, like a Text or a Button.
  2. In the Style tab, find its text, like the Text's Content or the Button's Title.
  3. Type the words, with a name or a formula in braces: Coffees today: {count}.

The canvas shows the text with each variable's starting value; Preview shows the live values. Once the text has braces, the ⚡︎ button beside it turns orange, because the text now reads values. You can keep editing it as text.

#Formulas in braces

Everything between { and } is a formula:

TextWithShows
Hello, {name}!name AdaHello, Ada!
{count} {count == 1 ? 'coffee' : 'coffees'}count 22 coffees
Each of {people} pays {currency(total / people)}people 4, total 50Each of 4 pays $12.50
{count(filter(tasks, !it.done))} lefttwo tasks not done2 left
{user.firstName} {user.lastName}a record with firstName Ada and lastName LovelaceAda Lovelace
Due {formatDate(addDays(today(), 14), 'long')}Due, then the date two weeks from today
{item.title}inside a RepeaterThe current item's title

Money and dates are written the way the iPad's region writes them.

How values print in text:

  • Whole numbers have no decimals: 3, not 3.0.
  • true and false print as true and false.
  • null prints as nothing.
  • A list prints its items with a comma between them: 1, 2, 3.
  • A record prints its fields in braces and quotes, the way APIs send them.

To show a brace itself, type two: {{ shows {, and }} shows }.

#Where it works

WhereExamples
Text settings in the Style tabA Text's Content, a Button's or a Switch's Title, and the other settings you type words into
Text settings of stepsShow Message's Text, Show Alert's Title and Message
Fields in a stepA Call API's Headers, Query and Body, like Bearer {accessToken}, and Go to Screen's With

#When a name doesn't exist

Each formula in braces is checked like any other. A name that isn't one of your variables, like a typo in {nmae}, is an error in Issues: "There's nothing called nmae in “nmae”. Check the spelling, or add it in Data & Logic." Errors stop Preview and Finish until you fix them.

Everything inside the braces must be a formula, so words with spaces between them, like {first name}, are an error too. Write names without spaces ({firstName}), or put words in quotes.

If a formula in braces can't be worked out while the app runs, the text shows as you typed it, braces and all.

#See also