Use the function TextWidth() on a subset of your string obtained from the function left(), until it exceeds the length of the textbox, or whatever. Something like this.
void WrapPrint(int x, int y, int dest, int font, string t, int maxlen)
{
int i;
while(len(t) > 0)
{
i = 0;
while(TextWidth(font, left(t,i)) < maxlen && i <= len(t))
i++;
i--;
PrintString(x,y,dest,font,left(t,i));
t = right(t,len(t)-i);
y += FontHeight(font);
}
}
This won't separate the string by words though.