Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
12/10/2013 12:17:26 PM EDT
I know how to declare character variables and I know I can combine two text strings using " // ".  
'CAT' // 'FISH' becomes 'CATFISH'
But how do I handle indefinite lists of character strings?  Assume a file contains the list of three character strings:

THIS IS A TEST
OF THE EMERGENCY
BROADCAST SYSTEM.

If I want the character variable COMBINE to be 'THIS IS A TESTOF THE EMERGENCYBROADCAST SYSTEM', how do I program it?  Remember please that the next file the program processes might have 25 or whatever lines of text.

I'm paraphrasing here, but I've tried.....

10 read(100,*,end=11)
    COUNT = COUNT + 1
    go to 10
11 rewind 100
   do 12 I=1,COUNT
     read(100,*)LINE(I)
     COMBINE=COMBINE // LINE(I)
12 continue

...but it doesn't work.  

Thanks.
12/10/2013 12:19:09 PM EDT
[#1]
FUCK YOU FORTRAN!!!!!!!!!!!!!!!!!!

OP - Good luck on your project

When I was in school I was required to take fortran. The prof sucked; told us most would fail.  I searched out a tutor and couldn't find one.  Went to the dean to ask if he knew of one, he asked "we still teach fortran?"  I said "apparently."  He asked "why?" He was not much help.  I resorted to memorizing and regurgitating pages of code from the book on the exam.  I passed with a D.  My only D in college and I was damn glad to get it.  The prof was right, 85% withdrew or failed.
12/10/2013 12:23:35 PM EDT
[#2]
Make a loop that reads a line then tests for file EOF

It'll be file length independent.

http://gcc.gnu.org/onlinedocs/gfortran/IS_005fIOSTAT_005fEND.html
12/10/2013 12:43:19 PM EDT
[#3]
Quoted:
I know how to declare character variables and I know I can combine two text strings using " // ".  
'CAT' // 'FISH' becomes 'CATFISH'
But how do I handle indefinite lists of character strings?  Assume a file contains the list of three character strings:

THIS IS A TEST
OF THE EMERGENCY
BROADCAST SYSTEM.

If I want the character variable COMBINE to be 'THIS IS A TESTOF THE EMERGENCYBROADCAST SYSTEM', how do I program it?  Remember please that the next file the program processes might have 25 or whatever lines of text.

I'm paraphrasing here, but I've tried.....

10 read(100,*,end=11)
    COUNT = COUNT + 1

    go to 10
11 rewind 100
   do 12 I=1,COUNT
     read(100,*)LINE(I)
     COMBINE=COMBINE // LINE(I)
12 continue

...but it doesn't work.  

Thanks.
View Quote


Fortran gave me some of the worst headaches I've ever had.

When I took it we used IBM punch cards.

Yeah it was a long time ago and I'm an old fart.

You have my sympathies sir but that won't help you much.

In any case, good luck.
12/10/2013 12:48:05 PM EDT
[#4]
Can you test for an end of line character?
12/10/2013 12:56:49 PM EDT
[#5]
FORTRAN?  What, is that a kind of cuneiform found on ancient obelisks?
12/10/2013 1:14:16 PM EDT
[#6]
I thought FORTRAN was pretty easy, but I was AE so they kept it pretty simple for us.



Although, I did have one program fail. I even say down with the prof and went through it character by character... it was functionally identical to his, he couldn't find anything wrong with it, but it wouldn't compile.




Still aced the class.
12/10/2013 1:24:41 PM EDT
[#7]
FORTRAN taught me to love to love programming in binary and assembly languages.
12/10/2013 1:38:13 PM EDT
[#8]
I thought FORTRAN was as dead as latin.  I remember when the first PC's came out, the co. I worked for had a fortran language compiler for the pc.

I don't remember enough about it to help you though.  I haven't written a line of code since about 1982
12/10/2013 1:49:10 PM EDT
[#9]
Quote History
Quoted:
I thought FORTRAN was pretty easy, but I was AE so they kept it pretty simple for us.

Although, I did have one program fail. I even say down with the prof and went through it character by character... it was functionally identical to his, he couldn't find anything wrong with it, but it wouldn't compile.

Still aced the class.
View Quote



Same problem for me. Went to a peer and the teacher and they couldn't find the problem either. I got zero on the project and a C instead of an A.
12/10/2013 1:49:58 PM EDT
[#10]
Quoted:
I know how to declare character variables and I know I can combine two text strings using " // ".  
'CAT' // 'FISH' becomes 'CATFISH'
But how do I handle indefinite lists of character strings?  Assume a file contains the list of three character strings:

THIS IS A TEST
OF THE EMERGENCY
BROADCAST SYSTEM.

If I want the character variable COMBINE to be 'THIS IS A TESTOF THE EMERGENCYBROADCAST SYSTEM', how do I program it?  Remember please that the next file the program processes might have 25 or whatever lines of text.

I'm paraphrasing here, but I've tried.....

10 read(100,*,end=11)
    COUNT = COUNT + 1
    go to 10
11 rewind 100
   do 12 I=1,COUNT
     read(100,*)LINE(I)
     COMBINE=COMBINE // LINE(I)
12 continue

...but it doesn't work.  

Thanks.
View Quote


It's been 30 years, but the combining of strings is called  CONCATENATION.
The   //   is the concatenation operator
Google "Fortran Concatenation" may produce some examples.

12/10/2013 2:22:53 PM EDT
[#11]
Just add commas till it compiles
12/10/2013 2:29:36 PM EDT
[#12]
LEN function

eta: FORTRAN String Funtions
12/10/2013 3:50:17 PM EDT
[#13]
I was taught Fortran in the Army at Ft Lee, Virginia in September 1968. I had forgotten all of it by November 1968. Of cours I was in the Central Highlands by then and had no need for it.