Description
The Allocate
function reserves a memory area for data used by External DLL functions within a script. Not available in WinTask Lite.
Syntax
address=Allocate(<num>)
Parameter
<num>
, integer.
Return Value
address
, UNSIGNED type which must be declared beforehand. If the Allocate function fails, address
will be set to 0.
Example
dim MemPointer as unsigned
MemPointer=Allocate(80)
Example Code
'declare a variable to hold the memory address
dim pointer as unsigned
'reserve a 64-byte memory space
pointer=allocate(64)
'prepare a string to place in memory
wdir$=" "
'writes the zero-terminated string to memory
ret=PokeString(pointer,wdir$,0)
'In Win32, an A must be added to function which return a string
a=External("kernel32","GetWindowsDirectoryA",pointer,64)
'read the string through its memory address
var$=peekString$(pointer)
msgbox(var$)