[comp.lang.pascal] Arrays > 64K revisited

ts@uwasa.fi (Timo Salmi) (05/05/91)

In article <7408@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Bob Beauchaine) writes:
>In article <673056705.0@egsgate.FidoNet.Org> 
>Carl.Hu@f660.n250.z1.FidoNet.Org (Carl Hu) writes:
>>    I need to have arrays > 64K, does anybody know how to do that?
>
>  Sounds like it's time for a FAQ post.  To Timo: is there a 
>  reference in your archives for this question?  Seems it's been
>  getting a lot of air time recently.

This will be augmented on top of the information that already is
there on >64K into /pc/ts/tsfaq20b.arc update of tsfaq20.arc when I
release it in the near future. 

--- cut here, clipety clip clip ----
(* ========================================================================
   The code below is based on a UseNet posting in comp.lang.pascal
   by Naji Mouawad nmouawad@watmath.waterloo.edu. Naji's idea was for a
   vector, my adaptation is for a two-dimensional matrix. The realization
   of the idea is simpler than the one presented by Kent Porter in Dr.Dobb's
   Journal, March 1988. (Is something wrong, this is experimental.)
   ======================================================================== *)

const maxm = 150;
      maxn = 250;

type BigVectorType = array [1..maxn] of real;
     BigMatrixType = array [1..maxm] of ^BigVectorType;

var BigAPtr : BigMatrixType;

(* Create the dynamic variables *)
procedure MAKEBIG;
var i          : word;
    heapNeeded : longint;
begin
  heapNeeded := maxm * maxn * SizeOf(real) + maxm * 4 + 8196;
  if (MaxAvail <= heapNeeded) then
    begin writeln ('Out of memory'); halt; end;
  for i := 1 to maxm do New (BigAPtr[i]);
end;  (* makebig *)

(* Test that it works *)
procedure TEST;
var i, j : word;
begin
  for i := 1 to maxm do
    for j := 1 to maxn do
      BigAPtr[i]^[j] := i * j;
  {}
  writeln (BigAPtr[5]^[7] : 0:0);
  writeln (BigAPtr[maxm]^[maxn] : 0:0);
end;  (* test *)

(* The main program *)
begin
  writeln ('Big arrays test by Prof. Timo Salmi, Vaasa, Finland, 5-May-91');
  writeln;
  MAKEBIG;
  TEST;
end.
--- cut here ---

...................................................................
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