|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deciphering a tag character string
I have a string, eg 7f30.3 and I want to store things in the following way Code:
npos = 7 decform = true width = 30 ndp = 3 I need to read each character one by one. I am coding in fortran but I can try to code it should answer be given in C in the above way. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
how do you get 'true' from that?
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I meant set decform = .true. if 'f' is encountered I got something to work as follows: Code:
isChar = .false.
tag = "17f30.2"
n = LEN_TRIM(tag)
print '(A,A,A,I1)', 'tag = ', tag(:n), ', n = ', n
j = 0
do i = 1, n
if ( index('0123456789',tag(i:i)) > 0 ) then
j = j + 1
else
exit
endif
enddo
print *, 'j = ', j
npl = 0
itmp = 0
k = j
do i = 1, j
read(tag(i:i),*) itmp
print *, tag(i:i)
npl = npl + (itmp * (10 ** (k-1)) )
k = k - 1
enddo
print *, 'npl = ', npl
print *, ' '
k = 0
do i = j+2, n
if ( index('0123456789',tag(i:i)) > 0 ) then
k = k + 1
else
exit
endif
enddo
print *, 'k = ', k
iwid = 0
itmp = 0
l = k
print *, j+2, j+2+k-1
do i = j+2, j+2+k-1
read(tag(i:i),*) itmp
print *, tag(i:i)
iwid = iwid + (itmp * (10 ** (l-1)) )
l = l - 1
enddo
print *, 'iwid = ', iwid |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help deciphering this if statement | Straitsfan | Shell Programming and Scripting | 8 | 12-06-2010 02:09 PM |
| Need help deciphering this | Straitsfan | UNIX for Dummies Questions & Answers | 3 | 04-28-2010 06:44 PM |
| Korn: How to loop through a string character by character | shew01 | Shell Programming and Scripting | 10 | 12-02-2008 06:58 AM |
| Help deciphering script | bbbngowc | Shell Programming and Scripting | 3 | 01-16-2008 12:57 PM |
| converting character string to hex string | axes | Programming | 5 | 09-20-2006 01:04 PM |
|
|