Tinderbox Forum

Formatting $MyString 1 value per line for a Stamp

Ok, I thought this would work, it doesn’t. I know I am close but no cigar.

I have $MyString=Name1;Name2;Name3:Name4

What I want is for each value of $MyString to be on a separate line, but this does not work. Not sure why.


TextValuesTest.tbx (88.6 KB)


$MyString = "Name1;Name2;Name3;Name4";
$Text = $MyString.replace(";","\n");


$MyList = $MyString;

format() and .format() do note work on String data. Strings, Tinderbox’s most basic data type are assumed to be formatted, if only because the output of formatting is normally a string (here, $Text!).

See the modified file be.ow. Select note ‘Container1’ and run stamps ‘String to paragraphs’ and ‘String to paragraphs 2’ on it. the results can be seen in notes ‘Test1’ and ‘Test2’.

TextValuesTest-ed.tbx (92.6 KB)

1 Like

One more question: is there a way instead of the results to $Text, rather use the run command to send to the clipboard?


I’m curious, why use a string, e.g., $MyString, and not a set, e.g. $MySet?

I sense there is a question behind this question. IOW, you’re trying to coerce some text into a list to use outside Tinderbox. Knowing the wider context might help.

Meanwhile, in brief, assuming we capture a value in user attribute $ReturnString, then this copies it to the clipboard:

1 Like

I thought initially it might be simpler to use a string instead of a set. I think of sets when I want to auto de-dupe which in this case I did not need to.

Anyway, I am glad I did not because I learned something today. I did not realize I had a gap in not know .format does not work in a string, only a list or set. In addition, I learned 2 new commands: replace to work on a string and pbcopy to send to the clipboard.

I am rolling!

1 Like

The operator format() converts various Tinderbox objects to strings.

This is why format() or .format() don’t work with a String-type source

.format() works on data types too with Strings and Booleans as the outliers. I presume this is because all non-strings have assumptions you can make about them:

Action, Font, File and URL are essentially special types of String.

1 Like