Newsgroups: comp.lang.pascal Path: utzoo!utgpu!watserv1!watmath!nmouawad From: nmouawad@watmath.waterloo.edu (Naji Mouawad) Subject: Re: need a little flexibility Message-ID: <1991Apr24.235739.25115@watmath.waterloo.edu> Organization: University of Waterloo References: <1991Apr24.183315.7997@ux1.cso.uiuc.edu> Date: Wed, 24 Apr 1991 23:57:39 GMT Lines: 57 In article <1991Apr24.183315.7997@ux1.cso.uiuc.edu> amead@s.psych.uiuc.edu (alan mead) writes: >Hi. I want to manipulate a data structure in the cleanest way possible >(after I write this, I'd like to minimize maintenance time). I've been >working with something like this: > >Block = record > x : byte; > y : byte; > ... > data : array[1..252] of byte; >end; > >but the elements of data are sometimes words instead of bytes and this >structure doesn't compile (I guess you cannot declare ABSOLUTE structures >in a type declaration?): > >Block = record > x : byte; > y : byte; > ... > data : array[1..252] of byte; > dataW: array[1..126] of word ABSOLUTE data; >end; > >And a variant record requires an exhaustive listing of it's fields right? I don't understand your last statement, it seems that a record of the following form: Block = record x : byte; y : byte; case boolean of True : (data : array[1..252] of byte); False: (dataw: array[1..126] of word); end; would do the trick. You could access just as easily data or dataw as follows: Var B : block; w : word; Begin w := 12345; b.data[i] := hi(w); b.dataw[i] := w; end. Isn't this what you were looking for ? --Naji. -- ------------------------------------------------------------------- | Naji Mouawad | nmouawad@watmath.waterloo.edu | | University |---------------------------------------------------| | Of Waterloo | "The Stranger in us is our most familiar Self" |