Code archives/Miscellaneous/PokeString, PeekString to banks

This code has not been declared by its author to be Public Domain code, and therefore should not be assumed to be so.

Download source code

PokeString, PeekString to banks by AngelEyes
(Posted 25 years ago)
The string is poked in as an Integer containing the length of the string, followed by the string itself - this means it takes 4+len(string$) bytes to store.
Function PokeString(bank,offset,s$)
	PokeInt bank,offset,Len(s$)
	For i = 1 To Len(s$)
		PokeByte(bank,offset+i+3, Asc(Mid$(s$,i,1)))
	Next
End Function

Function PeekString$(bank,offset,s$)
	l = PeekInt(bank,offset)
	s$ = ""
	For i = 1 To l
		s$ = s$ + Chr$(PeekByte(bank,offset+i+3))
	Next
	Return s$
End Function

Comments

None.

Code Archives Forum