Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!16448591%VUVAXCOM.BITNET@wiscvm.wisc.EDU From: 16448591%VUVAXCOM.BITNET@wiscvm.wisc.EDU Newsgroups: comp.lang.pascal Subject: RE: implementing large arrays in turbo pascal Message-ID: <9834@brl-adm.ARPA> Date: Sat, 17-Oct-87 13:33:05 EDT Article-I.D.: brl-adm.9834 Posted: Sat Oct 17 13:33:05 1987 Date-Received: Sun, 18-Oct-87 11:14:35 EDT Sender: news@brl-adm.ARPA Lines: 50 Subject: implementing large arrays in turbo pascal in <973@cup.portal.com> you write: >I need some help in writing a turbo pascal program. What I am >trying to do is to write an image processing program that >will be able to do image compression and enhancement. The >problem i run across is the memorylimit in turbo, and in >having a clean way of implementing a large matrix in turbo. > The only way I know to get around turbo pascal's memory limit with large arrays is to create an array that is really a structure referenced through a pointer. For example, suppose the following types are defined in a program: array_type = array[0..45000] of real; array_ptr = ^array_type; These type statements set up the type for the array and a pointer to it. Now, let's suppose that the following is part of a var statement: var array1, array2 : array_ptr; This sets up pointers for array1 and array2 for the large arrays. To use them, all that is needed is to create the arrays pointed to by the pointers array1 and array2. This is done using the new statment such as: new(array1); Remember, when you actually access the arrays, this is done through a pointer, so any reference to the arrays would be something like: array2^[200] := 2.0; There is a *big* problem with this approach to making the large arrays is that you have to know prior to creating the arrays if there is enough memory available for them, otherwise all sorts of things can happen (usually the program just dies, but evil things can happen, too). There is also an advantage to this approach since the arrays are referenced through pointers, you can always dispose of them when you are done and free up memory for whatever else. ============================================================================== | Mark Schaffer | BITNET: 164485913@vuvaxcom | | Villanova University | UUCP: ...{ihnp4!psuvax1,burdvax,cbmvax,pyrnj,bpa} | | (Go Wildcats!) | !vu-vlsi!excalibur!164485913 | ==============================================================================