Mark@hamster.business.uwo.ca (02/27/91)
I have a program that uses a large array. I would like to have more than 64k available. Is this possible? About 128k would be nice. I would even accept 64k if it did not decrease the memory for normal variables. I have tp6.0. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Mark Bramwell, VE3PZR Located in sunny London, Ontario Internet: mark@hamster.business.uwo.ca IP Address: 129.100.22.100 Packet: VE3PZR @ VE3GYQ UWO Phone: (519) 661-3714
lowey@herald.usask.ca (Kevin Lowey) (02/27/91)
From article <26146@adm.brl.mil>, by Mark@hamster.business.uwo.ca: > I have a program that uses a large array. I would like to have more than > 64k available. Is this possible? About 128k would be nice. I would even > accept 64k if it did not decrease the memory for normal variables. I have > tp6.0. Turbo Pascal is limited in that it works in the real mode of Intel x86 processors. It uses 64K segments, which means that no one data structure can be larger than 64K. Here is a trick that I use. Remember that a two dimensional array is really conceptually an "array of arrays". Using this principle, I can have an array of POINTERS. Each pointer can point to a 64K array. I can then access element 25,3 of this array with something like VARIABLE[23]^[3]. For example (from memory, so forgive minor mistakes): Program Test; TYPE largearray : array [1..60000] of byte; large_ptr : ^largearray; VAR The_Big_Array [array [1..20] of large_ptr; Don't forget to use "New" to allocate the arrays pointed to by The_Big_Array, and use "Dispose" when it is no longer necessary. - Kevin Lowey
steve@cad0.arch.unsw.oz.au (Stephen Peter) (02/27/91)
In article <26146@adm.brl.mil> Mark@hamster.business.uwo.ca writes: >I have a program that uses a large array. I would like to have more than >64k available. Is this possible? About 128k would be nice. I would even >accept 64k if it did not decrease the memory for normal variables. I have >tp6.0. > >Mark Bramwell, VE3PZR Located in sunny London, Ontario > >Internet: mark@hamster.business.uwo.ca IP Address: 129.100.22.100 Try declaring the array via a pointer : ---------------- type big_array = array [1..32000] of integer; { or something... < 64 K } big_ptr = ^big_array; var arr1, arr2 : big_ptr; begin new(arr1); new(arr2); { allocate the memory } arr1^[30000] := 2; end. -------------- Note that because these variables are pointers they only take up 4 bytes in the first data segment, the data is allocated from the heap. If you don't always want all the space, declare the variables (as above) and then use GetMem to allocate just the amount you actually need. Hope this helps! Stephen. -- _--_|\ / \ Stephen Peter steve@cad0.arch.unsw.oz.au \_.--._/<------------------------------------------------------------------- v School of Architecture, University of New South Wales, Australia
ts@uwasa.fi (Timo Salmi) (02/28/91)
In article <26146@adm.brl.mil> Mark@hamster.business.uwo.ca writes: >I have a program that uses a large array. I would like to have more than >64k available. Is this possible? About 128k would be nice. I would even : One option: Take a look at the inevitable /pc/ts/tsfaq17.arc for further information and references. Available by anonymous ftp from our site. ................................................................... Prof. Timo Salmi Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37 School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun