[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Date: Thu, 3 Sep 1992 13:00 EDT
From: firstname.lastname@example.org (Robin Kladke (303-977-9760))
Can someone tell me if this is a bug (or i am just reading the documentation wrong based on
how i think it should be)?
I am taking messages in "binary" form and parsing off integers and strings. I declare one
array to be of element type 'string-char and to be of a length that allows 4 bytes (string-chars)
per integer and one byte (string-char) per character. This works peachy. In order to
parse the array, i displace an integer array to it using the following code:
Be careful doing this, as it exposes the byte order of the machine. If
you're using this for network communication, you can have portability
On the other hand, if this code only needs to run in Genera, there are
some existing macro packages that provide this functionality. They are
called DEFSTORAGE, and there's a version in the SYS package and another
(incompatible) one in LMFS. They let you use a syntax similar to
DEFSTRUCT to describe the layout of objects in byte arrays and define
accessors for them.
For example, if the binary message contains 6 integers followed by a string and i want to parse off
the 3rd integer, num-ints will be 1, start-byte will be 8 (because there are 4 bytes per int).
Well, this doesn't work at all. I assumed that :displaced-index-offset was the index in the primary
array. This code works if i use start-int (in this example, 2), the index into the displaced integer
The Symbolics documentation section "Displaced and Indirect Arrays with
Offsets" says that the index offset "is added to the subscript given."
It doesn't say that it's first scaled by the ratio of the element sizes
of the two arrays.