Author Topic: String too long for window  (Read 169 times)


  • Newbie
  • *
  • Posts: 2
    • View Profile
String too long for window
« on: July 10, 2017 »
How do I print a string that is too long for the window width and have it wrap? Do I need to have it in smaller chunks like text1$, text2$ instead of just text$ being one long string?


  • Administrator
  • Hero Member
  • *****
  • Posts: 549
    • View Profile
Re: String too long for window
« Reply #1 on: July 14, 2017 »
Sorry, there's no built in way to deal with that :( Usually I only use text for displaying score and information with pretty well known length that I can split up in forhand. But here's a simple procedure you can try:

Code: [Select]
create font 0, "courier new", 28

text$ = "Hello there, this is a really long and interesting text that "
text = text + "will hopefully span over multiple rows. My uncle used "
text = text + "to write really long texts, but they weren't that funny."

_PrintLong text
wait keydown

procedure PrintLong(txt$)
if fwidth(0, txt) >= width(primary)
index = 0
while fwidth(0, left(txt, index)) < width(primary)
index = index + 1
wln left(txt, index - 1)
txt = right(txt, index - 1)
wln txt

If you need a more generic way to word-wrap text at a certain x position and with a certain width I could probably write some more advanced function.
« Last Edit: July 14, 2017 by Marcus »