home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!boulder!colorado.edu!ejh
- From: ejh@khonshu.colorado.edu (Edward J. Hartnett)
- Subject: Re: swapping bytes on a two byte integer
- In-Reply-To: lionel@quark.enet.dec.com's message of Tue, 15 Dec 1992 17:24:55 GMT
- Message-ID: <EJH.92Dec16102651@khonshu.colorado.edu>
- Sender: news@colorado.edu (The Daily Planet)
- Nntp-Posting-Host: khonshu.colorado.edu
- Organization: CIRES, University of Colorado
- References: <BzB6rI.LI7@acsu.buffalo.edu> <1992Dec15.172455.12204@e2big.mko.dec.com>
- Date: 16 Dec 92 10:26:51
- Lines: 31
-
- In article <1992Dec15.172455.12204@e2big.mko.dec.com> lionel@quark.enet.dec.com (Steve Lionel) writes:
-
- In article <BzB6rI.LI7@acsu.buffalo.edu>, acscmaw@ubvmsb.cc.buffalo.edu
- (MARK WIECZOREK) writes:
- |>
- |>I have a very simple problem. I have a binary data file composed of two byte
- |>integers. After reading the data I would like to change the order of the
- |>bytes and write the result to a file. I've looked through the vax fortran
- |>manuals and couldn't find a way to do this. Any help would be greatly
- |>appreciated.
- |>
-
- The simplest way is to use ISHFTC(value,8,16). If you have a lot of these to
- do and want something faster, you can define the variable as a record structure
- with two byte elements and swap the bytes yourself.
-
- The next major release of Fortran for OpenVMS VAX will have a feature that will
- do the byte-swapping for you on input or output, if selected.
- --
-
- Well, this might generate some flames, but C is perfect for doing this
- sort of thing. If you can hook up a C function to your fortran
- program, or write a simple C program to do the byte shifting, that
- might be the easiest way to go.
-
- Please! I love FORTRAN! REALLY!
- --
- Don't blame me, I voted against Amendment 2!
-
- Edward Hartnett ejh@khonshu.colorado.edu
-
-