One little endian question

Kenneth Brody kenbrody at bestweb.net
Sun Mar 2 21:35:26 PST 2008


Quoting Jeff Harrison (Sun, 2 Mar 2008 13:19:37 -0800 (PST)):

> --- "Brian K. White" <brian at aljex.com> wrote:
[...]
>> ... I dare say none of
>> us has any endianness tests in our normal apps and
>> we survived this long :)
>
> Yes, apparently I am going where no man has gone
> before :-)

Perhaps no _man_, but Laura certainly did with her screen painter.

Of course, she has the advantage of reading a screen file, which has
a known "magic number" at the start of the file header.  If you don't
mind a little bit of overhead, you could read the header of a known
screen (you could use @FI and @SN) to determine the byte order.  Do
you have a copy of her toolkit?

Laura says I can post this from her file.  I think you can follow the
basic logic.

==========
::txt = fP_path { fP_name { "/screen." { fP_scrname { "":
::handle = open(txt,"rwb"):
:handle le "0":errorbox "Unable to open screen file.\n\nScreen name\n" {
   txt; fP_scrname = ""; return:
::x = read(handle,header,"64"):
bigend:mid(header,"1","2") eq chr("62")&chr("17")::
litend:mid(header,"1","2") eq chr("17")&chr("62")::
:not bigend and not litend:errorbox "Unable to load invalid screen" <
   fP_scrname & "\n\nUnknown magic number."; fP_scrname = ""; return:
==========

In the rest of the code, simply use "if bigend" or "if litend" as needed.

-- 
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list