The is no good way of doing it. A solution that ignores the obvious issue that you are likely using a proportional font is to:
Assume you will have a line break after no more than 40 characters.
Search MyString for the last "," prior to the 40th character.
Record the position of that "," in a variable EndLine1.
Update a variable MyStringLine1 := MyString [1 to EndLine1]
Search MyString for the last "," prior to EndLine1 + 41
Record the position of that "," in a variable EndLine2.
Update a variable MyStringLine2 := MyString [EndLine1 + 1 to EndLine2]
etc.
As you can see, it is tedious and doesn't account for proportional spacing.
Malcolm