HexDump
This program produces a hexadecimal dump of a text or binary input file...
Support:   MS DOS  MS Win  Linux  Stratus VOS 
 
Output from hexdump.q
 

  **************************************************************************
  * Program: hexdump.q                                                     *
  * Purpose: Produces a hexadecimal dump of an input file in either text   *
  *          or binary mode.                                               *
  * Syntax.: quikcode.exe hexdump.q {filename} [optional record length]    *
  * Output.: Output is written to file, hexdump.out.                       *
  * Modes..: Binary -> If a record length parameter is provided, the file  *
  *                    is opened in binary mode and dumped as fixed-length *
  *                    records.                                            *
  *          Text ---> If no record length parameter is provided, the file *
  *                    is opened in text mode and dumped according to the  *
  *                    size of the record as determined by the position of *
  *                    linefeed/carriage control character combinations in *
  *                    the file.  In text mode, linefeed/carriage control  *
  *                    characters are omitted from the hexdump output.     *
  **************************************************************************

  equate RECMAX         to 32000

  option ifasize = RECMAX
  option ofasize = 110
  option wstsize = 1000

  equate hex-hi-lo      to wst1-2
    equate hex-hi       to wst1
    equate hex-lo       to wst2
  equate hex-hi-100     to wst3-102
    equate hex-hi-1     to wst3
  equate hex-lo-100     to wst103-202
    equate hex-lo-1     to wst103
  equate char-100       to wst203-302
    equate char-1       to wst203
  equate ifa-sub1       to wst303-304-i
  equate ifa-sub2       to wst305-306-i
  equate ifa-sub3       to wst307-308-i
  equate ifa-sub4       to wst309-310-i
  equate filemode       to wst311-316

  if prmb-recsize = 0
    open ifa prma1-200   Text 32000
    move 'Text'         to filemode
  else
    open ifa prma1-200 Binary 32000
    move 'Binary'       to filemode
    if prmb is numeric
      move prmb1-5      to ifa-recsize
    else
      display 'Error - Parameter B is not numeric'
      end.

  open ofa 'hexdump.out' 110 1100

  move 'File: '          to ofa
  move prma              to ofa7-110
  write ofa
  move 'Mode: '          to ofa
  move filemode          to ofa7-12
  write ofa
  move spaces            to ofa
  write ofa

100 read ifa at eof 500
  move 1                 to ifa-sub1
  move 1                 to ifa-sub2
  move 1                 to ifa-sub3
  move 100               to ifa-sub4
  move spaces            to hex-hi-100
  move spaces            to hex-lo-100
  move spaces            to char-100
  move spaces            to ofa
  write ofa
  write ofa
  move 'Record #:'       to ofa1
  move ifa-recnum        to ofa11-15
  move 'Length:'         to ofa19
  move ifa-recsize       to ofa27-31
  write ofa
  if ifa-recsize = 0
    go to 100.
110 if ifa-sub1 <= ifa-recsize
    go to 120.
  perform 300
  move 110               to ofa-recsize
  go to 100.
120 if ifa-sub2 > 100
    perform 300.
  hexexpd ifa1(ifa-sub1) to hex-hi-lo
  move hex-hi            to hex-hi-1(ifa-sub2)
  move hex-lo            to hex-lo-1(ifa-sub2)
  perform 400            * Move Character
  add 1 to ifa-sub1
  add 1 to ifa-sub2
  go to 110.

300 move spaces            to ofa
  write ofa
  if ifa-sub2 > 100
    move 108 to ofa-recsize
  else
    move ifa-sub2        to ofa-recsize
    add 3 to ofa-recsize.
  move '1...+...10....+...20....+...30....+...40....+...50....+.'  to ofa5-60
  move '..60....+...70....+...80....+...90....+....'               to ofa61-103
  move ifa-sub3          to ofa1-5
  move ifa-sub4          to ofa104-108
  move ifa-sub1          to ifa-sub3
  add 100 to ifa-sub4
  write ofa
  move spaces            to ofa
  move hex-hi-100        to ofa5-105
  write ofa
  move hex-lo-100        to ofa5-105
  write ofa
  move spaces            to ofa
  move all               to ofa5-105
  write ofa
  move char-100          to ofa5-105
  write ofa
  move spaces            to ofa
  move spaces            to hex-hi-100
  move spaces            to hex-lo-100
  move spaces            to char-100
  move 1                 to ifa-sub2
399 exit

  * Move Character
400 if ifa1(ifa-sub1)   = x'00'
    or ifa1(ifa-sub1) = x'0a'
    or ifa1(ifa-sub1) = x'0d'
    or ifa1(ifa-sub1) = x'07'
    or ifa1(ifa-sub1) = x'08'
    or ifa1(ifa-sub1) = x'09'
    or ifa1(ifa-sub1) = x'1a'
    or ifa1(ifa-sub1) = x'1b'
    or ifa1(ifa-sub1) = x'ff'
    * move space         to char-1(ifa-sub2)
  else
    move ifa1(ifa-sub1)  to char-1(ifa-sub2).
499 exit

500 close ifa
  close ofa
  system 'quikcode list.q hexdump.out 10'
  end

*** End of hexdump.q ***
QuikCode Language