This is a little function I wrote to make a string of text be displayed at a certain location at a certain width. I have already chopped 9 lines off the code and was wondering if anybody could shorten it more.
Graphics 800,600,32,2
SetBuffer BackBuffer()
textsquare("This is the test of the new textsquare function and I need to ramble to make sure it works, so that is what I am doing. I hope it works well. Yeah. This is getting old. Yup. It is. Ok. That ought to be long enough now.",100,20,400)
Flip
WaitKey
End
Function textsquare(incoming$,x,y,width)
word$=""
tempx=x
tempy=y
While incoming$<>""
word$=""
While Right$(word$,1)<>" " And incoming$<>""
word$=word$+Left$(incoming$,1)
incoming$=Right$(incoming$,Len(incoming$)-1)
Wend
If tempx+StringWidth(word$)<width+x
Text(tempx,tempy,word$)
tempx=tempx+StringWidth(word$)
Else
tempx=x
tempy=tempy+FontHeight()
Text(tempx,tempy,word$)
tempx=tempx+StringWidth(word$)
End If
Wend
End Function
Good luck!
Graphics 800,600,32,2
SetBuffer BackBuffer()
textsquare("This is the test of the new textsquare function and I need to ramble to make sure it works, so that is what I am doing. I hope it works well. Yeah. This is getting old. Yup. It is. Ok. That ought to be long enough now.",100,20,400)
Flip
WaitKey
End
Function textsquare(incoming$,x,y,width)
word$=""
tempx=x
tempy=y
While incoming$<>""
word$=""
While Right$(word$,1)<>" " And incoming$<>""
word$=word$+Left$(incoming$,1)
incoming$=Right$(incoming$,Len(incoming$)-1)
Wend
If tempx+StringWidth(word$)<width+x
Text(tempx,tempy,word$)
tempx=tempx+StringWidth(word$)
Else
tempx=x
tempy=tempy+FontHeight()
Text(tempx,tempy,word$)
tempx=tempx+StringWidth(word$)
End If
Wend
End Function
Good luck!