[comp.sys.ibm.pc] Turbo Pascal : Need more variable space

bisanabi@vrdxhq.UUCP (Paul Paloski) (02/04/87)

I have a program written in Turbo Pascal which can't compile because
of variable space required.  Some of my variables are quite large.
For example, a 27x27x27 array of reals takes about 39K.  I also have
vectors of this array.  Is there any way for me to increase the size
of the variable space in Turbo ??

-- 

:-- Paul
:
:UUCP:	...!{decuac, rlgvax, seismo, verdix}!vrdxhq!bisanabi

timothym@tekigm2.UUCP (02/06/87)

In article <2941@vrdxhq.UUCP> bisanabi@vrdxhq.UUCP (Paul Paloski) writes:
>Is there any way for me to increase the size of the variable space in Turbo ?
>:-- Paul
>:UUCP:	...!{decuac, rlgvax, seismo, verdix}!vrdxhq!bisanabi

No: Symbol table space is limited to 64k in more compilers than you can shake
a stick at. Even some 'GOOD' C compilers capable of HUGE Memory models.


-- 
Tim Margeson (206)253-5240
PO Box 3500  d/s C1-937                          @@   'Who said that?'  
Vancouver, WA. 98668
{amd..hplabs}cae780!tektronix!tekigm2!timothym (this changes daily)

dalegass@dalcs.UUCP (02/12/87)

In article <1443@tekigm2.TEK.COM>, timothym@tekigm2.UUCP writes:
> In article <2941@vrdxhq.UUCP> bisanabi@vrdxhq.UUCP (Paul Paloski) writes:
> >Is there any way for me to increase the size of the variable space in Turbo ?
> >:-- Paul
> >:UUCP:	...!{decuac, rlgvax, seismo, verdix}!vrdxhq!bisanabi
> 

Turbo only restricts you to 64K for the global data segment.  I.E. Variables
declared outside of any procedures.  Within each procedure I believe you can
have 64K.

Also, using dynamic variable allocation, you can access any amount of arrays
as long as each is less than 64K.

e.g. (Forgive my style, it's been awhile since I used pascal...)

type big_array = array[1..27,1..27,1..27] of integer;
	big_ptr = ^big_array;

var a,b,c,d,e: big_ptr;

begin
	new(a); new(b); new(c); new(d); new(e);  {allocate the variables}
	.
	.
	.
From this point on you can access any of the above arrays.  Note that you
must access them as 'a^' and 'b^', because a-e are merely points to the
arrays.

> 
> No: Symbol table space is limited to 64k in more compilers than you can shake
> a stick at. Even some 'GOOD' C compilers capable of HUGE Memory models.

This is not quite right...  I believe that most compilers restrict you to
64k for the global variables, and 64k per array.  However, in most you can
access the full memory using dynamic allocation (or large memory models.)

Hope this helps...

dalegass@dalcs
dalegass@dalcsug

madd@bucsb.bu.edu.UUCP (02/24/87)

In article <2941@vrdxhq.UUCP> bisanabi@vrdxhq.UUCP (Paul Paloski) writes:
>
>I have a program written in Turbo Pascal which can't compile because
>of variable space required.  Some of my variables are quite large.
>For example, a 27x27x27 array of reals takes about 39K.  I also have
>vectors of this array.  Is there any way for me to increase the size
>of the variable space in Turbo ??

This is basically a kludge, but it does work.  The way to do it is to
make your arrays some kind of type, like "arraytype".  Then make a
type which is a pointer to "arraytype".  Then use the new() function
to get a pointer to an array of that size from the heap.  To reference
the array, you'll need to give a ^ symbol between the array name and
the subscript.  A simple example follows, which allocates several
large arrays (more than 64k):

program largearrays;

type arraytype = array[0..32000] of real; { define type of array }
     arrayptr = ^arraytype;               { define pointer to that type }

var a1,a2,a3,a4,a5 : arrayptr; { define pointers to several large arrays }

begin
  new(a1); { get space for each array }
  new(a2);
  new(a3);
  new(a4);
  new(a5);

  for i:= 0 to 32000 do begin { clear all of the arrays }
    a1^[i]:= 0.0;
    a2^[i]:= 0.0;
    a3^[i]:= 0.0;
    a4^[i]:= 0.0;
    a5^[i]:= 0.0;
  end;

 { put anything else you want in here }

end.

It's too bad Turbo Pascal can't use more than 64K of data, but at
least it allows you to tap the full memory of your pc by allocating it
via pointers.  Of course, if your pc doesn't have that much memory,
the new() allocation fails and your program will die horribly.

Hope this helps.  It's the simplest solution I've yet come up with.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   - Jim Frost * The Madd Hacker -
UUCP:  ..!harvard!bu-cs!bucsb!madd | ARPANET: madd@bucsb.bu.edu
CSNET: madd%bucsb@bu-cs            | BITNET:  cscc71c@bostonu
-------------------------------+---+------------------------------------
"Oh beer, oh beer." -- Me      |      [=(BEER) <- Bud the Beer (cheers!)