remove last letter in a string

BlitzMax Forums/BlitzMax Beginners Area/remove last letter in a string

slenkar(Posted 2008) [#1]
how do i remove the last letter in a string?


GfK(Posted 2008) [#2]
newString = Left(oldString, Len(oldString)-1)



Brucey(Posted 2008) [#3]
and the less retro way would be..

newString = oldString[..oldString.length - 2]

(this assumes the string is long enough, of course...)


SebHoll(Posted 2008) [#4]
(this assumes the string is long enough, of course...)

newString = oldString[..Max(0,oldString.length - 1)]

Fail safe!

Oh, and I think you only need to subtract 1. ;-)


Brucey(Posted 2008) [#5]
Well, wha'ya know... and there was me thinking it was 0..length-1 based.... far, far too many hours in Java it seems.

;-)