You can only acess a file in sequential order. forwards.
You can get aroud this by making a memblock of the file, then use
a int to point to a position in the file.
newname$=ptffile$+".ptf"
newnamelength= len(newname$)
namediff= (newnamelength-namelength)
newentryssize=sizeofentries+namediff
`need to change size of entries to match
newmemblocksize=get memblock size(2)
newmemblocksize=newmemblocksize+namediff
`calc new file size
before=mbpos-(namelength+2)
`point before changes to ptf data
make memblock 3,newmemblocksize
copy memblock 2,3,0,0, (mbpos)
`before=before-1
write memblock byte 3,before,newnamelength
`write memblock byte 3,before,42
before=before+1
for w=1 to newnamelength
write memblock byte 3,before, asc( mid$(newname$,w) )
before=before+1
next w
write memblock byte 3,before, 0
`write ascii 0
before=before+1
write memblock dword 3,2, newentryssize
`change entry size
copy memblock 2,3,(mbpos+0),before, (get memblock size(2)- (mbpos) )
`reattach rest of dat file
`must update entry pointers because new file name causes offset change
mbpos=0
basicly the code writes a string in to a memblock.
To insert data you will need to resize the memblock since the size of the memblock will change.
also copy the data that is after the insert point to preserve it.
The code was ripped from one of my progs dont try to use it as it is, it wont work.
RAF are complex things to do (and debug) just delete the old file and write a new one, save yourself the bother.