Path: utzoo!attcan!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!david From: david@swift.cs.tcd.ie Newsgroups: comp.sys.mac.programmer Subject: Problems with THINK Pascal Message-ID: <1991Jan11.190458.7714@swift.cs.tcd.ie> Date: 11 Jan 91 19:04:58 GMT Organization: Computer Science Department, Trinity College Dublin Lines: 59 I have just purchased a new version of THINK Pascal to run on a Mac II si, and have encountered two problems when dealing with PACKED ARRAYs of BOOLEAN. i. The mapping for the elements of "A: PACKED ARRAY [0..7] OF BOOLEAN" is not the same as the mapping for "B: PACKED ARRAY [1..8] OF BOOLEAN" If A and B are viewed as bytes, then setting A[0]:=TRUE corresponds to setting the byte value to 1, ... setting A[6]:=TRUE corresponds to setting the byte value to 64, and setting A[7]:=TRUE corresponds to setting the byte value to 128 while setting B[1]:=TRUE corresponds to setting the byte value to 2, ... setting B[7]:=TRUE corresponds to setting the byte value to 128, and setting B[8]:=TRUE corresponds to setting the byte value to 1 yet the manual states that the elements of a packed data structure are allocated sequentially ii. Assigning a boolean value based on the comparison of elements from packed boolean data structures, will not always produce the correct result Given the declarations VAR RESULT: BOOLEAN; LOGICAL1,LOGICAL2: PACKED ARRAY[0..7] OF BOOLEAN; the statement RESULT:=LOGICAL1[3]=LOGICAL2[3]; will produce the following results LOGICAL[1] LOGICAL[2] RESULT ---------- ---------- ------ TRUE TRUE TRUE TRUE FALSE TRUE !!! FALSE TRUE FALSE FALSE FALSE TRUE This problem can be solved by using an if statement IF LOGICAL1[3] = LOGICAL2[3] THEN RESULT:=TRUE ELSE RESULT:=FALSE; I would like to know if I am missing something obvious, if there are any other known problems in this area, etc. David M. Abrahamson, Dept. of Computer Science, Trinity College, Dublin 2, Ireland. E-Mail to David@CS.TCD.IE