Accessing a string sequentially

BlitzMax Forums/BlitzMax Beginners Area/Accessing a string sequentially

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.

you can't treat a string quite like you can an array.

stringy:String="something"
Print Stringy
StrInsert(stringy, "test", 4)
Print Stringy
StrReplaceIndex(stringy, "-", 4)
StrReplaceIndex(stringy, "-", 5)
StrReplaceIndex(stringy, "-", 6)
StrReplaceIndex(stringy, "-", 7)
Print stringy

StrFillRange(stringy, "*", 4, 7)
Print Stringy
StrFillRange(stringy, ".", 4, 7)
Print stringy



Rem
	Inserts inString into the SourceStr at the specified index and expands the string to accommodate the change
EndRem
Function StrInsert(SourceStr:String Var, inString:String, Index:Int)
	SourceStr = SourceStr[..Index] + inString + SourceStr[Index..]
End Function



Function StrReplaceIndex(SourceStr:String Var, replaceString:String, Index:Int)
	SourceStr = SourceStr[..Index] + replaceString + SourceStr[Index+1..]
End Function


Function StrFillRange(SourceStr:String Var, ReplaceString:String, StartIndex:Int, EndIndex:Int)

	For Local i = StartIndex To EndIndex
		StrReplaceIndex(SourceStr, ReplaceString, i)
	Next
	
End Function