[comp.sys.mac.programmer] LSP Triviality.

borcelf@jacobs.cs.orst.edu (Fernando Borcel) (04/27/89)

I'm having a little bit of a problem assigning a value from a packed array
to another value from a packed array of the same base type.  The problem is,
one array contains a sequence of bytes (characters).  But when I assign it
to the other array, it assigns in an integer size with the higher byte cleared
, as it would when assigning to a non-packed array.

What's the trivial solution to this trivial problem?

Here's my code, just in case (BTW, I'm using LSP2.0p1)



linetype = array[1..80] of byte;
line = ^linetype;
FileBufferType = packed array[1..BUFFSIZE] of byte;
FileBufPtr = ^FileBufferType;


error := FSRead(EncRefNum, BytesRead, @FileBuffer^);


i:=1;
FileIndex:=1

repeat
buffer^[i] := FileBuffer^[FileIndex];
i := i + 1;
FileIndex := FileIndex + 1;
until ......


_____

Trivial enough?  Well, it doesn't work!

		-Fernando Borcel
"Tact is the ability to tell a man he has an open mind when he has a
hole in his head."  Internet:     borcelf@jacobs.cs.ORST.EDU
                    UUCP:{tektronix,hp-pcd}!orstcs!jacobs.cs.orst.edu!borcelf

siegel@endor.harvard.edu (Rich Siegel) (04/28/89)

In article <10228@orstcs.CS.ORST.EDU> borcelf@jacobs.cs.orst.edu (Fernando Borcel) writes:
>
>linetype = array[1..80] of byte;

	The problem is that the so-called "Byte" data type is really a word-
sized type; it's a holdover from Lisa Pascal. If you want the correct
result, declare both arrays to be arrays of "SignedByte", which is a one-byte
type.

>error := FSRead(EncRefNum, BytesRead, @FileBuffer^);

	Just a comment: the expression "@FileBuffer^" is redundant, since
FileBuffer is already a pointer. Just cast "FileBuffer" to a Ptr, as in

	err := FSRead(encRefNum, bytesRead, Ptr(FileBuffer));

		--Rich


~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

 "She told me to make myself comfortable, so I pulled down my pants
 and sat in the pudding." -Emo Phillips
~~~~~~~~~~~~~~~