Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: EQUIVALENCE Stmt?

by swampyankee (Parson)
on Apr 30, 2009 at 22:47 UTC ( #761179=note: print w/replies, xml ) Need Help??


in reply to EQUIVALENCE Stmt?

I've programmed Fortran for about thirty-five years (I started before the existence of Fortran-77, when FORTRAN didn't have a character data type). I've found the EQUIVALENCE statement to be a major source of buggery and non-portability. Indeed, it was banned in most of the shops in which I worked. I did use it a lot in PLM (product life-cycle management) programming using the Catia CDM/CDS API, and have used it for when I've needed to twiddle bits (yeah, I've done it in Fortran), but I've also had to maintain code where EQUIVALENCEd variables were used to read ASCII flat files, a practice which I believe is hideous, and completely unnecessary.

Use pack and unpack. It's the closest you'll get to Fortran's FORMATted I/O


Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

Replies are listed 'Best First'.
Re^2: EQUIVALENCE Stmt?
by Brainwavesurfer (Initiate) on May 01, 2009 at 12:46 UTC
    Dear Corion, pemungkah, johngg, swampyankee, Thank you all so much for the replies.. I guess what I'm after is simply code simplification, the data is all character-based, no binary, i just wanted to do either EQUIVALENCE, or use the VMS Fortran's capability to do STRUCTUREs, so the the first 10 chars of INREC mapped directly to COLUMN1, the next 10 mapped directly to COLUMN2, and so forth. I've already done it with the following snippets.. $CDXCODE = NibbleItOff(8); where NibbleItOff is defined as:
    ###################################################################### +############### sub NibbleItOff { my $Field_Length = shift; my $Output_String; #print "NibbleItOff>>inrec->$inrec<\n"; print "NibbleItOff>>Field_Leng +th->$Field_Length<\n"; $Output_String = substr( $inrec, 0, $Field_Length ); $inrec = substr( $inrec, $Field_Length ); #print "NibbleItOff>>inrec->$inrec<\n"; print "NibbleItOff>>Output_Str +ing->$Output_String<\n"; return $Output_String; } ###################################################################### +###############
    using either EQUIVALENCE, or appropiate STRUCTUREs, that could be eliminated.. Just a passing thought... I'll gladly look up the UNPACK, but it seems to be for binary data, tho.. Thanks for all the hints!!! Jim
      Also Kudos to all the FORTRAN programmers (Or ex-FORTRAN)!!! It was and still is a wonderful language for math as well as whatever else it could do with extensions.. My flavor we used for the longest time was the DEC VAX line.. When we left the VAXen, after a long time of searching, I choose Perl for the next language, as it ran on VAX, PC, Unix, Linux, etc.. (no CP/M, tho! ;-) But that first computer is long gone...) Guess I just dated my self.. Now I've just written my first interface with MS-SQL Server..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://761179]
help
Chatterbox?
and the rats come out to play...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-10-17 01:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (218 votes). Check out past polls.

    Notices?