home *** CD-ROM | disk | FTP | other *** search
- '*****************************************************************************
-
- 'Copyright (c) 1987 Marcel Madonna
-
- 'MEMALLOC.BAS is an example of the use of the memory management routines.
- ' To compile it, type:
-
- ' qb memalloc /l qbdos.exe;
- ' link memalloc /cp:16000;
- ' del memalloc.obj
- '
- ' You may have to play with the /cp parameter if you don't have 640K on
- ' your computer
-
-
- ' Allocate 64K of memory - indicate that each array element will be
- ' 80 characters long
-
- MemSize% = 64
- Array.Size% = 80
-
- Call DosMAllc(Block%, MemSize%, Array.Size%, Rc%)
- If Rc% <> 0 then
- Print "Error allocating memory: code ";Rc%
- End
- End if
-
- ' Let's fill the array with consecutive numbers
-
- String.Out$ = Space$(Array.Size%)
- Index% = 0
- While Rc% = 0
- Mid$(String.Out$,1,Len(Str$(Index%))) = Str$(Index%)
- Call DosMPut(Block%, Index%, String.Out$, Rc%)
- If Rc% <> 0 then
- Print Rc%, "Memory array is filled with ";Index%;" records";
- Else
- Index% = Index% + 1
- End if
- Wend
- Rc% = 0
- Mem.Ubound% = Index%-1
-
- ' Let's retrieve every element in the array and print it on the consloe
-
- String.Out$ = Space$(Array.Size%)
- Index% = 0
- While Rc% = 0
- Call DosMGet(Block%, Index%, String.Out$, Rc%)
- If Rc% <> 0 then
- Print "All records have been re-read"
- Else
- Print String.out$
- Index% = Index% + 1
- End if
- Wend
-
- ' Finally, let's de-allocate the array
-
- Call DosMFree(0, Rc%)
-
-
-
-
- 'Call DosMInit(Array.Size%, Rc%)
-
-
-
-