Strings Question

BlitzMax Forums/BlitzMax Programming/Strings Question

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

A string is basically an array of individual characters, so using BlitzMAX's array slicing tools, you can easily change the length of the string.

mystring=mystring[..n]

Resizes the mystring variable to make it n characters long. If the string is shorter than n characters, BlitzMAX will create space for the new characters. If the string is currently longer than n characters, BlitzMAX will remove all the characters after position n.

Edit: In case you aren't familiar with string / array slicing:

result=existingStringOrArray[start..end]

Takes the contents of an array or string between elements start and end and copies them into another variable.

If you omit the start parameter, the first element is used, if you omit the last parameter, the last element is used.

So to copy a string completely:

local newStr:String=oldStr[..]