Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ECNCDC.BITNET!MARK From: MARK@ECNCDC.BITNET Newsgroups: comp.lang.modula2 Subject: Re: Clever way to deal with this? Message-ID: Date: 13 Feb 90 05:32:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List Organization: The Internet Lines: 33 I'm not sure this will work, because I have never tried it myself in a language like Modula-2, but I think that this (or very close to this) will take care of your problem for you: TYPE pRec = POINTER TO Rec; Rec = RECORD NumChars : CARDINAL; Chars : ARRAY [ 0..MAX( CARDINAL ) ] OF CHAR; END; VAR Data : pRec; Num : CARDINAL; BEGIN Num = { Some cardinal number }; ALLOCATE( pRec, SIZE( Num ) + Num ); (* assuming CHARs are 1 byte *) ... etc. You have to be careful not to do the following: 1) Don't have Rec as the type of any parameter, but always access it through the dereferencing of the pointer. 2) Don't rely on ANY Modula-2 string procedures, but always use NumChars for the integrity check. Hope this works for you, Mark Morrell Software Specialist Western Illinois University MARK @ ECNCDC