Silverfrost Forums

Welcome to our forums

ENCODE AND DECODE

20 May 2008 5:58 #3225

How can I convert numbers to character strings (and vice-versa)? I used to use ENCODE and DECODE but I don't dee these in the help. 😦 For example looking at a hex dump I have the following two bytes 32 38 i.e. 28 I need an integer with 28.

20 May 2008 7:16 #3226

I don't think that ENCODE and DECODE were ever part of the fortran standard. I remember they were VAX extensions. Certainly on the VAX they were equivalent to an internal read and write, where instead of reading from and writing to a unit number a character string variable replaced the unit number. This is part of the fortran standard.

READ(character_string_variable,*)K

and

WRITE(character_string_variable,'(I8)')K

20 May 2008 7:18 #3227

came out wrong !

READ(character_string_variable,*)K 


WRITE(character_string_variable,'(I8)')K
20 May 2008 10:09 #3228

Here are some examples on other websites: http://gcc.gnu.org/onlinedocs/gcc-3.1.1/g77/ENCODE-and-DECODE.html and http://docs.hp.com/cgi-bin/doc3k/B3150190021.12118/44 http://docs.hp.com/cgi-bin/doc3k/B3150190021.12118/36

In your case for two characters, you will need the I2 format in the read statement described by John Regards

Ian

20 May 2008 10:22 #3229

I have a feeling that they were more than VAX-only extensions, and existed prior to the VAX. You can also give the statement number of a format statement if you wish.

E

22 May 2008 6:45 #3238

Actually, ENCODE and DECODE go back much farther than VAX/VMS. Before there was even a Digital Equipment Corp. The oldest implementation I am aware of was as library routines on the IBM 1620. That would be circa 1960, but it may be even older.

Please login to reply.