⟵ hearthere ⟶

Using str to combine text

using_str_to_combine_text
Set bookmark

How do I concatenate strings?

There is a function strAdd(str: ""; str "")see documentation.

But there is a faster way — using syntactic sugar


=:
str`"string 1" ++ "string 2"`

One + concatenates without spaces.

Two ++ with a space.

Is it possible to use field data and reference to lines of code?

Yes, if the value is specified in quotes, it will be processed as a string. If without quotes, then as a Totum code element.


=:
str`$S1 + "/" + $S2 ++ $S3` S1: "Cucumbers" S2: 2 S3: "(halved)" // Result: "Cucumbers/2 (halved)"

Can str be used inside functions?

Yes, str can be used inside functions:


=:
linkToDataText(title: "Window Title"; text: str`"Text from" ++ $num ++ "lines"`) num: 10

How do I move to a new line when adding strings?

There is a quick variable $#nl that adds a newline character:

= : selectRowListForSelect(table: 'user'; field: 'name'; previewscode: $code)

code: str` $s1 + $#nl + $s2` 

    s1: "=: listCreate(item: $rowCreate)"
    s2: "rowCreate: rowCreate(field: 'title' = 'Title'; field: 'value' = 'Calculated preview')"