FB II Compiler
Use memory as a virtual disk
Here's the easiest way to do it:
* gmy4Mptr& is the pointer you need to allocate
* 4096*1024*1024 is 4Meg
* offset& is the offset to the location to poke to
* data% is from 0-255, bytes in other words
* Disposptr is the function to call to destroy the pointer at the very end
gmy4Mptr& = FN NEWPTR _clear(4096*1024*1024)Take into consideration:
LONG IF gmy4Mptr&<>0
POKE gmy4Mptr& + offset&, data%
OsErr% = FN DISPOSPTR(gmy4Mptr&)
* 4M allocations may not work in small memory environments
* if you crash in the middle, there's no way I know of to dispose your broken pointer and you've automatically lost 4M of memory(d'oh!)
* data is from 0 to 255, in this case, cuz POKE does bytes, you can use POKE WORD but I've never used it, so...
* After you get your routines perfected, some will say handles are better than pointers... You have to remember to HLOCK and HUNLOCK the handles when you do this(a bit trickier, pointers are better to start with in my opinion).