I attempted to test the allocmem program from the help file, but it fails to work.
I don't understand why.
$Main
autodefine "off"
openconsole
DEF mymem as MEMORY
IF ALLOCMEM(mymem,100,10)
PRINT "Allocated 1000 bytes of memory"
FREEMEM mymem
else
print "Error in allocation"
ENDIF
DO:UNTIL INKEY$ <> ""
closeconsole
END
Read the manual. Here's the important part about MEMALLOC function:
Return value
Returns 0 on success or -1 on failure. Function may fail if the size requested is larger than the amount of free memory available.
So, what you need is either change the test like this:
IF ALLOCMEM(mymem,100,10)=0
or change the position of messages like this:
IF ALLOCMEM(mymem,100,10)
print "Error in allocation"
else
PRINT "Allocated 1000 bytes of memory"
FREEMEM mymem
ENDIF
Barney
:-[
Thanks Barney, I should RTFM. I took the example at face value and it is apparently wrong and should be corrected.