blitzmax has awesome string functions which makes it easier to do wordwrap:
this to put the text in lines in a list:
local the_text$=YOURTEXT
local width=YOURBOXWIDTH
If TextWidth(the_text) > width - 9
Local word_array$[] = the_text.split(" ")
Local new_string$
Local long_string$
Local iter = 0
While iter<word_array.length
Local a$ = word_array[iter]
long_string$ = new_string + A$
If TextWidth(long_string)>width-9
line_list.addlast(new_string)
new_string = a+" "
long_string=""
If iter = word_array.length-1
line_list.addlast(New_String)
EndIf
Else
new_string = new_string + a + " "
If iter=word_array.length-1
line_list.addlast(new_string)
EndIf
EndIf
iter = iter + 1
Wend
Else
line_list.addlast(the_text)
EndIf
current_line = (line_list.count() - (height /TextHeight("hi")))+2
this is to draw the text:
local height=YOURBOXHEIGHT
local
Local line_position=0
Local iter=0
For Local a$ = EachIn line_list
If line_position > current_line - 1
If line_position < (current_line + (height / TextHeight(a)) )-1
DrawText a,x+9,y+(iter*TextHeight(a))+5
iter=iter+1
EndIf
EndIf
line_position=line_position+1
Next
this to put the text in lines in a list:
local the_text$=YOURTEXT
local width=YOURBOXWIDTH
If TextWidth(the_text) > width - 9
Local word_array$[] = the_text.split(" ")
Local new_string$
Local long_string$
Local iter = 0
While iter<word_array.length
Local a$ = word_array[iter]
long_string$ = new_string + A$
If TextWidth(long_string)>width-9
line_list.addlast(new_string)
new_string = a+" "
long_string=""
If iter = word_array.length-1
line_list.addlast(New_String)
EndIf
Else
new_string = new_string + a + " "
If iter=word_array.length-1
line_list.addlast(new_string)
EndIf
EndIf
iter = iter + 1
Wend
Else
line_list.addlast(the_text)
EndIf
current_line = (line_list.count() - (height /TextHeight("hi")))+2
this is to draw the text:
local height=YOURBOXHEIGHT
local
Local line_position=0
Local iter=0
For Local a$ = EachIn line_list
If line_position > current_line - 1
If line_position < (current_line + (height / TextHeight(a)) )-1
DrawText a,x+9,y+(iter*TextHeight(a))+5
iter=iter+1
EndIf
EndIf
line_position=line_position+1
Next