replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Reading a text file: detecting a semi colon
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading a text file: detecting a semi colon

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Fri Jun 22, 2012 9:18 am    Post subject: Reading a text file: detecting a semi colon Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Fri Jun 22, 2012 9:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group