Deleting the last element in a string?

BlitzMax Forums/BlitzMax Programming/Deleting the last element in a string?

Bukky(Posted 2006) [#1]
Hello again,

Right now I'm implementing the high score system in my game and I am having trouble with users using the delete key.

I found the following piece of code in the code archives:


Else If aKeytoGet = 8 Or aKeytoGet = 4 'AscII For Backspace And Delete
   					If Len( tempText$ ) > 0 Then tempText$ = Left$( tempText$, Len(tempText$) -1 )	



but it doesnt seem to work quite correctly.

Basically I'll enter in a name, then delete part of it, then insert some new characters, but the characters which I initially deleted seem to be popping up at the end of my final string!

Anyone have any suggestions?


N(Posted 2006) [#2]
This should work.

If tempText.Length > 0 Then tempText$ = tempText$[..tempText.Length-1]

As for the problem with them popping up again, well, that's probably somewhere else in your code.


Bukky(Posted 2006) [#3]
Thanks! It works fine now!