Trim$ and Lset$ problem

Blitz3D Forums/Blitz3D Beginners Area/Trim$ and Lset$ problem

BigH(Posted 2004) [#1]
A$="ABCD"
aa=Len(A$)
Text 10,10,aa
LSet$(A$,19)
bb=Len(A$)
Text 10,30,bb
Trim$(A$)
cc=Len(A$)
Text 10,50,cc

Can someone please explain why I get the answers:
aa=4
bb=4
cc=4

instead of:
aa=4
bb=19
cc=4

Many thanks.


soja(Posted 2004) [#2]
Because LSet$ and Trim$ (and other related string functions) don't actually change the string you give them. They make a copy of the string and change it. To do what you want, just put "a$=" in front of the two lines.
A$="ABCD"
aa=Len(A$)
Text 10,10,aa
a$=LSet$(A$,19)
bb=Len(A$)
Text 10,30,bb
a$=Trim$(A$)
cc=Len(A$)
Text 10,50,cc 



BigH(Posted 2004) [#3]
Thanks for that.