Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!inesc!unl!unl!jgp From: jgp@fctunl.rccn.pt (Jose Goncalo Pedro) Newsgroups: comp.lang.pascal Subject: Re: Dynamic arrays in TP5.0 Message-ID: Date: 10 Jul 90 18:15:24 GMT References: <1831@krafla.rhi.hi.is> <1990Jul8.200026.29195@mthvax.cs.miami.edu> Sender: news@fctunl.rccn.pt (USENET News System) Organization: Universidade Nova de Lisboa -- Lisbon, Portugal Lines: 47 In-Reply-To: mathrich@mthvax.cs.miami.edu's message of 8 Jul 90 20:00:26 GMT In article <1990Jul8.200026.29195@mthvax.cs.miami.edu> mathrich@mthvax.cs.miami.edu (Rich Winkel) writes: In <1831@krafla.rhi.hi.is> binni@rhi.hi.is (Brynjolfur Thorsson) writes: [ something deleted ] >Program dynamic; >Var > y : ^array [1..10] of Real; <---- > x : Real; >Begin > GetMem(y, SizeOf(^y)); <---- > ^y[5]:=12.34; <---- > x :=^y[3]; <---- >End. I believe this will work. Rich It will work, but the size of the array not dinamic. What you probably want is: Var y : array [1..LargeNumber] of Real ; ... GetMem( y, SizeOfArray * SizeOf(Real) ) ; y^[5] := 12.34 ; x := y^[3] ; You should turn off Range Checking if you intend to create arrays of more than LargeNumber size. The only problem is that there is no range checking. If you need it, enclose said code in a procedure which checks array bounds before assigning/reading from the array, and {$R-} before and {$R+} after (or another letter, I don't remember now) -jp -- --- Jose Goncalo Pedro BITNET/Internet: jgp@fctunl.rccn.pt +---------------------------------+ UUCP: jgp@unl.uucp | Departamento de Informatica +----------------------------------+ | Universidade Nova de Lisboa 2825 Monte Caparica, PORTUGAL | +--------------------------------------------------------------------+