Anyone able to point out what's wrong here?
REM - Save the path we have found.
function SavePath(NodeIndex as integer, startX as integer, startY as integer)
mbIndex as integer
cX as integer
cY as integer
cIndex as integer
memSize as integer
Found as boolean
memSize = 0
Found = 0
cIndex = NodeIndex
repeat
cX = gCList(cIndex).xpos
cY = gCList(cIndex).ypos
inc memSize, 1
cIndex = gCList(cIndex).parent
until cX = startX and cY = startY
repeat
mbIndex = rnd(65535)
if memblock exist(mbIndex) = 0 then Found = 1
until Found = 1
make memblock mbIndex, memSize*4
for i=0 to memSize-1
write memblock word mbIndex, i*4, gCList(NodeIndex).xpos
write memblock word mbIndex, i*4+2, gCList(NodeIndex).ypos
NodeIndex = gCList(NodeIndex).parent
next i
endfunction mbIndex
Keep getting an out of bounds error on the memblock:
Runtime Error 5101 - Memblock range is illegal at line xxx
EDIT:
This has been solved. For those of you with similar errors, my problem was that I was looking for a memblock in the range 0-65535, but memblocks only range from 1-255.
So the correct code is: mbIndex = rnd(254)+1