Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!rphroy!caen!math.lsa.umich.edu!sharkey!bnlux1.bnl.gov!kushmer From: kushmer@bnlux1.bnl.gov (christopher kushmerick) Newsgroups: comp.lang.pascal Subject: Re: need dynamic array on heap Message-ID: <1991Apr15.002131.14174@bnlux1.bnl.gov> Date: 15 Apr 91 00:21:31 GMT References: <1991Apr12.234843.9031@ux1.cso.uiuc.edu> <1991Apr14.205511.11509@watmath.waterloo.edu> Organization: Brookhaven National Laboratory, Upton, NY 11973 Lines: 34 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 -- Chris Kushmerick kciremhsuK sirhC kushmer@bnlux1.bnl.gov <===Try this one first kushmerick@pofvax.sunysb.edu