How do I write a string at the end of the memory?
PokeS will write in front of the memory.
I want to read a file into the memory and add this string: tXñ¦Ï¾µ¦ª£ø¡>þ?ÄiA¿Ð to the end of the memory.
Write string at memory end
Something like :
Depending on the nature of the file you may wish to add some kind of 'terminator' before appending the string etc.
Code: Select all
fileName$ = "myFile.dat" ;Make sure this is a valid file.
text$ = "tXñ¦Ï¾µ¦ª£ø¡>þ?ÄiA¿Ð"
lenFile = FileSize(fileName$)
If lenFile > 0
;Allocate sufficient memory
mem = AllocateMemory(lenFile + (Len(text$)+1)*SizeOf(CHARACTER))
If mem
If ReadFile(1, fileName$)
ReadData(1, mem, lenFile)
CloseFile(1)
PokeS(mem + lenFile, text$)
Else
MessageRequester("Problem!", "Can't open file!")
EndIf
Else
MessageRequester("Problem!", "Insufficient memory!")
EndIf
Else
MessageRequester("Problem!", "File is either a folder or is empty!")
EndIf
I may look like a mule, but I'm not a complete ass.