Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucbvax!agate!root From: forags@violet.berkeley.edu Newsgroups: comp.lang.fortran Subject: Re: ENCODE and DECODE ... Message-ID: <1989Aug11.162714.25029@agate.berkeley.edu> Date: 11 Aug 89 16:27:14 GMT References: <1989Aug10.220842.18863@bpdsun1.uucp> Distribution: na Organization: University of California, Berkeley Lines: 39 ENCODE is like a Fortran-77 "internal write" (formatted write to memory) statement. Its syntax was: ENCODE (nchr, fmt, address) iolist where nchr is the number of characters to write, fmt a Fortran format number, and address is the name of the variable in which you want to store the result. For example, suppose you had integer variables for day, month, year and wanted to form a character string date like dd/mm/yy. (this is a slight mixture of Fortran-66 and 77): INTEGER DAY, MONTH, YEAR CHARACTER*8 DATE C C USING ENCODE ENCODE (8,10,DATE) DAY, MONTH, YEAR 10 FORMAT (I2,'/',I2,'/',I2) C C USING FORTRAN-77 INTERNAL WRITE WRITE (DATE,10) DAY, MONTH, YEAR DECODE is the reverse of ENCODE, that is, a formatted read from memory. To continue with the example, to read DAY, MONTH, and YEAR out of DATE: C C USING DECODE DECODE (8,20,DATE) DAY, MONTH, YEAR 20 FORMAT (I2,1X,I2,1X,I2) C C USING FORTRAN-77 INTERNAL READ READ (DATE,20) DAY, MONTH, YEAR Al Stangenberger Dept. of Forestry & Resource Mgt. forags@violet.berkeley.edu 145 Mulford Hall - Univ. of Calif. uucp: ucbvax!ucbviolet!forags Berkeley, CA 94720 BITNET: FORAGS AT UCBVIOLE (415) 642-4424