Path: utzoo!attcan!uunet!snorkelwacker!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple2 Subject: Re: ORCA/Pascal dynamic arrays Keywords: dynamic Message-ID: <42642@apple.Apple.COM> Date: 5 Jul 90 01:10:11 GMT References: <368@ankh.ftl.fl.us> Organization: Apple Computer Inc, Cupertino, CA Lines: 36 In article <368@ankh.ftl.fl.us> chin@ankh.ftl.fl.us (Albert Chin) writes: >Is it possible to do the following in Pascal, like in C: > >char *pointer; >.. >pointer=malloc(4000*sizeof(char)); /* dynamically allocate pointer[4000] */ Sure: ---------- type MyArrayType = array[1..4000] of char; var MyArrayPtr: ^MyArrayType; ... new(MyArrayPtr); MyArrayPtr^[100] := 'x'; ---------- Or, if you prefer: ---------- type MyArrayType = array[1..4000] of char; MyPtrType = ^MyArrayType; var MyArrayPtr: MyPtrType; ... MyArrayPtr := MyPtrType(NewHandle(4000,_ownerid,attrLocked+attrFixed,nil)^); { note the type-cast to "MyPtrType" and the "^" to dereference the handle } ---------- -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.