mjs84
Aerospace
- Aug 20, 2003
- 27
I need to build a string based on some input data. The data is coming from user input from a motif application so I don't know the length of any piece of data.
Here is my code:
character*50 str0,s0
character*50 str1,s1
character*50 str2,s2
character*50 str3,s3
character*10 str4,s4
character*10 str5,s5
character*70 elemID
integer*4 lenchr
c *** note: s0 thru s5 are variable from motif applic.***
str0 = s0(1:lentrim(s0))
str1 = s1(1:lentrim(s1))
.
.
.
str6 = s6(1:lentrim(s6))
elemID = str0 // ',' // str1 // ',' // str2 // ',' //
& str3 // ',' // str4 // ',' // str5
open(1,"filename", status="UNKNOWN"
write(1,'(a,2x,i4)') elemID, lenchr
c *** end of code ***
When I print out the values, I get the correct values for all the separate variables, ie...
str0 = base
str1 = A
str2 = B
str3 = C
str4 = D
str5 = E
When I print out 'eleID' and 'lenchr', I expect this:
'base,A,B,C,D,E 14'
... but what i get is:
'base 4'
I am assuming this has something to do with the string declarations, but I'm not sure. I know that when all the strings are added up, they will be less than 70 characters, but I don't know the length of any of the particular fields.
Any help would be greatly appreciated.
Regards,
mjs84
Here is my code:
character*50 str0,s0
character*50 str1,s1
character*50 str2,s2
character*50 str3,s3
character*10 str4,s4
character*10 str5,s5
character*70 elemID
integer*4 lenchr
c *** note: s0 thru s5 are variable from motif applic.***
str0 = s0(1:lentrim(s0))
str1 = s1(1:lentrim(s1))
.
.
.
str6 = s6(1:lentrim(s6))
elemID = str0 // ',' // str1 // ',' // str2 // ',' //
& str3 // ',' // str4 // ',' // str5
open(1,"filename", status="UNKNOWN"
write(1,'(a,2x,i4)') elemID, lenchr
c *** end of code ***
When I print out the values, I get the correct values for all the separate variables, ie...
str0 = base
str1 = A
str2 = B
str3 = C
str4 = D
str5 = E
When I print out 'eleID' and 'lenchr', I expect this:
'base,A,B,C,D,E 14'
... but what i get is:
'base 4'
I am assuming this has something to do with the string declarations, but I'm not sure. I know that when all the strings are added up, they will be less than 70 characters, but I don't know the length of any of the particular fields.
Any help would be greatly appreciated.
Regards,
mjs84