home *** CD-ROM | disk | FTP | other *** search
- program STIVPDEMO; { demonstration of VP }
-
- uses STI_VPTR, { virtual pointer unit }
- CRT; { standard CRT unit }
-
- Type
- DataRec = record { example data record }
- Data : string[50]; { the data }
- Page : word; { the page number }
- end;
- DataPtr = ^DataRec; { pointer to it }
-
- Var
- TestData : array[1..NUMPAGES] of STI_VPointer; { array of virtual pointer }
- Loop : word; { general loop variable }
-
- {---------------------------------------------------------------------------}
-
- procedure Explain;
-
- Var
- Dummy : char;
-
- begin
- writeln(' STIVPDEM.PAS');
- writeln;
- writeln(' This is a demonstration of STI_PTR, a unit that gives');
- writeln(' the ability to use Virtual Memory Pointers.');
- writeln;
- writeln(' Press any key to continue.....');
- repeat until keypressed;
- Dummy := ReadKey;
- end;
-
- {---------------------------------------------------------------------------}
-
- begin
- ClrScr; { wipe the screen }
- Explain;
- ClrScr;
- WriteLn('Available Memory = ',MaxAvail);
- Writeln('Initialising the VP system');
- STI_VPInitialise('STI_VPTR.SWP', { swap file name }
- NUMPAGES, { number of pages (GLOBAL VAL) }
- sizeof(DataRec)); { size of a page }
- Writeln('Allocating the memory');
- for Loop := 1 to NUMPAGES do { loop to NUMPAGES }
- begin
- STI_VPGetMem(TestData[Loop]); { get virtual memory }
- end;
- Writeln('Assigning data to the memory');
- for Loop := 1 to NUMPAGES do { loop & assign data }
- begin { take note of type cast }
- DataPtr(TestData[Loop])^.Data := 'Software Technology International';
- DataPtr(TestData[Loop])^.Page := Loop;
- end;
- Writeln('Reading the memory');
- for Loop := 1 to NUMPAGES do { loop and print data }
- begin { again type cast is needed }
- GotoXY(1,6);
- WriteLn(DataPtr(TestData[Loop])^.Data,'/',
- DataPtr(TestData[Loop])^.Page,'/',Loop);
- end;
- Writeln('Freeing the memory');
- for Loop := 1 to NUMPAGES do
- begin
- STI_VPFreeMem(Addr(TestData[Loop])); { free memory }
- end; { MUST USE ADDR HERE OR ELSE }
- { THE MEMORY IS NOT FREED }
- Writeln('Closing Down the sysytem');
- STI_VPClose; { close and erase swap file }
- Writeln('Available Memory = ',MaxAvail);
- end.
-
-
-
-
-
-
-