Newsgroups: comp.lang.pascal
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!ux1.cso.uiuc.edu!s.psych.uiuc.edu!amead
From: amead@s.psych.uiuc.edu (alan mead)
Subject: Re: need dynamic array on heap
Message-ID: <1991Apr15.045412.15425@ux1.cso.uiuc.edu>
Sender: usenet@ux1.cso.uiuc.edu (News)
Organization: University of Illinois at Urbana
References: <1991Apr12.234843.9031@ux1.cso.uiuc.edu> <1991Apr14.205511.11509@watmath.waterloo.edu> <1991Apr15.002131.14174@bnlux1.bnl.gov>
Date: Mon, 15 Apr 1991 04:54:12 GMT
Lines: 42

kushmer@bnlux1.bnl.gov (christopher kushmerick) writes:

>In article <1991Apr14.205511.11509@watmath.waterloo.edu> nmouawad@watmath.waterloo.edu (Naji Mouawad) writes:
>>In article <1991Apr12.234843.9031@ux1.cso.uiuc.edu> amead@s.psych.uiuc.edu (alan mead) writes:
>>>I want to put aside a chunk of the heap and then index it by byte like 
>>>  type
>>>    C_arrayType = array[1..1] of byte;
>>>  var
>>>    Buff : ^C_arrayType;
>>>  begin
>>>    GetMem( Buff,1000 );
>>>    Buff[1]^ := 2;
>>>  end.
>>  try Buff^[1] := 2;
>>
>But in general you'll need to do this:


>i := n;
>buff^[i] := m

>where n is the index to receive the value m

>This is because if you try, for example, buff^[10]=1 then
>the compiler will catch the out of range error.

>You'll still need to defeat _run time_ range checking with {$R-}
>but you can not defeat compile time range checking...


>-Chris

Yes.  Thanks all who have pointed out my mistake.  I have decided tha
there is no good reason not to declare the type as 1..65535, so I won't
have any run time error problems.

-alan

>-- 
>Chris Kushmerick                                 kciremhsuK sirhC
>kushmer@bnlux1.bnl.gov    <===Try this one first
>kushmerick@pofvax.sunysb.edu 
