TextAreaLen( textarea[,units] )

BlitzPlus Forums/BlitzPlus Programming/TextAreaLen( textarea[,units] )

what is the point in TextAreaLen( textarea[,units] )? well ofcourse it tells the length in chars of the text, but it according to the manual it should also be able to tell how many lines there are. It does'nt! It counts words!

Lazze

No, if you use '2' as the units it counts the number of lines. Actually quite handy. Essential even.

testtext$="This is just a test to test the meaining of TextAreaLen"

win=CreateWindow("test",20,40,800,600,Desktop(),7)
panel=CreatePanel(0,0,800,600,win,0)
txt=CreateTextArea(10,10,200,200,panel,1)
canvas=CreateCanvas(220,10,200,200,panel)
SetBuffer CanvasBuffer(canvas)
ClsColor 255,255,255
Cls
Color 0,0,0
SetTextAreaText txt,testtext$
LockTextArea txt
lines1=TextAreaLen(txt,1)
lines2=TextAreaLen(txt,2)

Notify "TextAreaLen(txt,1): "+lines1+"    TextAreaLen(txt,2): "+lines2  
While WaitEvent()<>$803
Wend


this gives me
TextAreaLen(txt,1): 55 TextAreaLen(txt,2): 45

Actually I was wrong. It does'nt count words - it counts characters except "space". Thats still not lines though, in my oppinion.

Lazze

When i ran that i got 2 as the number of lines

Strange!!! What version are you using? - I'm using v.1.39

Lazze

Same - i have all the updates installed.

That's really weird. Maybe we need a second (or third) opinion on this :o) I suppose it uses API or something like that. Could it be the Windows versions that makes the difference?
The reason I needed it was to use it as a wordwrapper for text printed on a canvas. I could write a function to do this, but using TextArea would be easier - or so i thought :o)

Lazze