Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ukma!rutgers!att!alberta!ubc-cs!fornax!mcdonald From: mcdonald@fornax.UUCP (Ken Mcdonald) Newsgroups: comp.sys.mac.programmer Subject: Allocating arrays? Keywords: Help requested. Message-ID: <867@fornax.UUCP> Date: 6 Feb 89 03:55:15 GMT Distribution: na Organization: School of Computing Science, SFU, Burnaby, B.C. Canada Lines: 49 Here's a simple question I'd appreciate some advice on. I'm using LightSpeed Pascal 2.0 (great product, by the way, Rich), and I want to dynamically allocate arrays of structured types, with the number of elements in the arraynot known until the array is actually allocated. The thing is, while I don't mind messing around with doing funny type conversions and pointer variables and things like that while I'm creating the array, I don't want to have to do things like that when I'm actually using it. I don't mind it if it's a hassle to create, but I don't want that kind of hassle to use it. So for example, I want to be able to do: program main; type complex=record re: real; im: real end cptr=^array[0..0] of complex; var C: cptr begin {Whatever is necessary here to create an array big enough to hold,say} {16 complexes, and set C to point to it.} C^[1].re := 1 C^[1].im := 1 ... end. Yes, I know that I'm missing lots of semicolons and where to put them, and so do you, now if only the compiler knew as well. Anyway, is there a way of doing something similar to the above and having it work? Do I have to adjust my subscripts? Are there better ways of doing the same thing? And how would I achieve the same effect, but with handles (relocateable blocks) instead of pointers (nonrelocateable blocks.) Please don't suggest linked structures, the Memory Manager imposes too much overhead on blocks for me to want to do this. If there is an easy answer in Inside Mac or my LSP manual, just point me to it, no need to wear your fingers out typing. Thanks, Ken McDonald {...!ubc-cs!mcdonald@fornax.uucp} P.S. Mail to my address isn't very reliable, so it might be better to post an answer, rather than mailing it. I think the question is of reasonably general interest (although perhaps kinda simple) to justify this.