View previous topic :: View next topic |
Author |
Message |
christyleomin
Joined: 08 Apr 2011 Posts: 155
|
Posted: Fri Jun 22, 2012 9:18 am Post subject: Reading a text file: detecting a semi colon |
|
|
I'm reading a text file-line by line, I assign values to certain variables.
I want to read a variable in a line after a colon i.e. (: )
Example- if the first line in text file is:
Number of node points:1000
So, 1000 should be assigned to a variable number_nodes but 1000 should be read after the colan(: )
Can anyone advide how to do this?
Thanks,
Christy |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Fri Jun 22, 2012 9:58 am Post subject: |
|
|
Try this example: Code: | character line*256 ! contents of line read
integer*4 n ! start of bnumber
integer*4 value ! value retreived
!
line = 'Number of node points:1000'
!
n = index (line,':') + 1
read (line(n:),*) value
!
write (*,*) n, value
end |
|
|
Back to top |
|
 |
|