UnmidStr

Discuss any general programming issues here
Post Reply
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

UnmidStr

Post 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
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: UnmidStr

Post by airsoftsoftwair »

Code: Select all

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