Unexpected Mid$ behaviour

BlitzMax Forums/BlitzMax Programming/Unexpected Mid$ behaviour

Local s$ = "1234"
Print "S="+Mid(s$,1,1)
Print "S="+Mid(s$,1,0)
Print "S="+Mid(s$,1,-1)
Print "S="+Mid(s$,2,1)
Print "S="+Mid(s$,2,0)
Print "S="+Mid(s$,2,-1)


result:


S=1
S=
S=1234
S=2
S=
S=234



I'd have expected a negative length to return the same as length=0 i.e. a null string!

like this does:

Function ccMid$(s$,start%,length%)
	If length<0 Then
		Return ""
	Else
		Return Mid(s$,start,length)
	EndIf
End Function