home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / fortran / 4768 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.9 KB  |  45 lines

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