Page 1 of 1

UnmidStr

Posted: Tue Apr 05, 2022 3:38 pm
by Flinx
Hello,

The UnmidStr function returns an enlarged string with some memory contents if it is called with a too large value for pos. I think it would make sense in this case not to change the string.

Code: Select all

Function p_PrintHex(st$)
	Debugstr$=""
	For i=0 To StrLen(st$, #ENCODING_RAW)-1
		Debugstr$=Debugstr$ .. MidStr((HexStr(ByteAsc(st$, i))),1).." "
	Next
	DebugPrint(Debugstr$)
EndFunction

t1$="abc"
p_PrintHex(t1$)
t2$=UnmidStr(t1$, 50, 1)
p_PrintHex(t2$)
DebugPrint(StrLen(t2$))
Ralf

Re: UnmidStr

Posted: Thu Apr 07, 2022 5:48 pm
by airsoftsoftwair

Code: Select all

- Fix: UnmidStr() didn't sanity check the position value that was passed to it