BTW, anyone knows if:
- is it possible to pass arrays inside function calls?
- is it possible to pass UDTs inside function calls?
In other languages, this is done by passing pointers or references. In DarkBasic, there are memblock that let you create arrays or vectors using a pointer-like type. Do you think that memblock shall be introduced in AppGameKit Tier-1, or shall we have to turn to Tier-2? I have no reasons or willing to revert to Tier-2, since I do not want that my hobby turns to be a nightmare, and I find AppGameKit Basic very easy to use and fast to deploy, as DarkBasicPro is.
Here is attached a short library I have written to manage that for my DarkBasicPro projects that requested to pass arrays into functions. I would like to do similar things in AGK.
function createMemblockArray(memId,rows,cols)
if memblock exist(memId) then delete Memblock memId
make memblock memId,((rows+1)*(cols+1))*4+8
ptr=get memblock ptr(memId)
fill memory ptr,0,(rows+1)*(cols+1)*4+8
write memblock dword memId,0,rows
write memblock dword memId,4,cols
endfunction
function writeMemblockArray(memId,row,col,value)
rows=memblock dword(memId, 0)
cols=memblock dword(memId, 4)
write memblock dword memId,(row*cols+col)*4+8,value
endfunction
function readMemblockArray(memId,row,col)
rows=memblock dword(memId, 0)
cols=memblock dword(memId, 4)
retVal=memblock dword(memId,(row*cols+col)*4+8)
endfunction retVal
function getMemblockArrayRows(memId)
retVal=memblock dword(memId, 0)
endfunction retVal
function getMemblockArrayCols(memId)
retVal=memblock dword(memId, 4)
endfunction retVal
function deleteMemblockArray(memId)
if memblock exist(memId) then delete memblock memId
endfunction
function createMemblockVector(memId,rows)
if memblock exist(memId) then delete Memblock memId
make memblock memId,(rows+2)*4
ptr=get memblock ptr(memId)
fill memory ptr,0,(rows+2)*4
write memblock dword memId,0,rows
endfunction
function writeMemblockVector(memId,row,value)
write memblock dword memId,row*4+4,value
endfunction
function readMemblockVector(memId,row)
retVal=memblock dword(memId,row*4+4)
endfunction retVal
function deleteMemblockVector(memId)
if memblock exist(memId) then delete memblock memId
endfunction
function getMemblockVectorRows(memId)
retVal=memblock dword(memId, 0)
endfunction retVal