Adding a character to a string
BlitzMax Forums/BlitzMax Beginners Area/Adding a character to a string
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.
Hi, newbie question ;-) Can anyone tell me how I can add a character to a string? Also, I'm a little confused as to whether a string is an array of characters (there seems to be conflicting opinions on this).
Effectively I want to do something like
string$="Hell"
string$:+"o"
Any help appreciated!
myString:String = "Hell"
myString = myString[..] + "o"
Print myString
Ok - so thats slices yeah? My other confusion is arrays and strings - if strings are an array of characters, how would this code work if you had an array of strings and say, wanted to repeat the above for mySting[3]?
thanks for the help
Ant, did you actually try what you typed in your post? Reason being is that is exactly how you do it! ;)
Also, a string is both a string AND an array of characters - it just depends on how you want to manipulate them.
I did and it printed a 0, which is why I asked.
Oh hang on - it was a typo. The code I used was:
text$=text$+"r"
Print "Text: "=text$
- instead of,
print "Text: "+text$
Which is why it wasnt working ;-)
Thanks guys!
Ant, did you actually try what you typed in your post? Reason being is that is exactly how you do it! ;)
Actually, what he typed in his post won't work, but not because you can't use '+' with strings, but because he's using a keyword as a variable name (String)