- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Will A. below do the same as B. but better (because not restricted to 1-5 characters) ?
A. READ(cv,*) iv
B. where fw (passed variable) equals field width:
if (fw.eq.1) then
read(cv,'(i1)') iv
elseif (fw.eq.2) then
read(cv,'(i2)') iv
elseif (fw.eq.3) then
read(cv,'(i3)') iv
elseif (fw.eq.4) then
read(cv,'(i4)') iv
elseif (fw.eq.5) then
read(cv,'(i5)') iv
endif
Thanks,
Keith
A. READ(cv,*) iv
B. where fw (passed variable) equals field width:
if (fw.eq.1) then
read(cv,'(i1)') iv
elseif (fw.eq.2) then
read(cv,'(i2)') iv
elseif (fw.eq.3) then
read(cv,'(i3)') iv
elseif (fw.eq.4) then
read(cv,'(i4)') iv
elseif (fw.eq.5) then
read(cv,'(i5)') iv
endif
Thanks,
Keith
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not quite - using * will allow input such as 2.45 or T and convert it to integer.
You don't need the complicated IF tests. Just use a format of '(BN,I5)')
Steve
You don't need the complicated IF tests. Just use a format of '(BN,I5)')
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve. BN works great.
Keith Richardson
Keith Richardson

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page