next up previous contents index
Next: Read and convert Up: Examples Previous: 16-bit Input and

Read and Write ASCII Hollerith Strings

     

The package provides utility routines to convert to and from ASCII 8-bit character code, which is the way we recommend to write text.

Since the package uses a 16-bit word as basic unit, the user should read and write Hollerith strings as bit strings (MODE=1), and pad with a blank to an even number of characters if necessary.

Of the computers for which this package exists, only IBM and CDC do not use the ASCII code internally. IBM uses 8-bit EBCDIC, CDC uses 6-bit DISPLAY code. However, when reading and writing on VAXes, the bytes in successive pairs of bytes have to be swapped in order to come out correctly, since they get swapped again when reading or writing, to make 16-bit words look correct.

Consequently, there exist two routines, SFRASC and STOASC on IBM, CDC, and VAX which perform the necessary conversion or swapping. The following examples show how they are used.

The previous routines CFRASC and CTOASC, working on blown-up strings will continue to exist.

The following example shows how to write Hollerith strings using both the old and new routines.

 

      PROGRAM EPEXA9
      DIMENSION IBIG(1000),ISMALL(1000),IBUF(1000),STRING(22)
      DATA STRING/
      1 'ABCD','EFGH','IJKL','MNOP','QRST','UVWX','YZab','cdef',
      2 'ghij','klmn','opqr','stuv','wxyz','0123','4567','89+-',
      3 '*/()','$=,.','#[]:','"_!&',4H'?<>,'@---'/
 C
 C   NW IS THE NUMBER OF CHARACTERS
 C
      NW= 88
      CALL EPINIT
 C
 C   USE PREVIOUS ROUTINES ( BLOW, CONVERT, BUNCH )
 C
      CALL BLO8W(STRING,1,IBIG,1,NW)
      CALL CTOASC(IBIG,NW)
      CALL BUN8W(IBIG,1,ISMALL,1,NW)
 C
 C   WRITE AS-BIT STRING (NOTE NUMBER OF 16-BIT WORDS ! )
 C
      CALL EPOUTS(11,1,(NW-1)/2+1,ISMALL,IBUF,IERR)
 C
 C--- String Conversion Routines  add same string behind first, write again
 C
      CALL STOASC(STRING,1,ISMALL,NW+1,NW)
      CALL EPOUTS(11,1,NW,ISMALL,IBUF,IERR)
      CALL EPCLOS(11,IBIG,IERR)
      CALL EPEND(11,IBIG,IERR)
      STOP
      END


Janne Saarela
Tue May 16 09:44:28 METDST 1995