How to write an integer value into a string with leading zeros?
How to write an integer value into a string with leading zeros?
(OP)
Help....
I am constructing a entity name in and I need to construct the name from strings and integers. This I know how to do, but I don't know how to get the leading zeros. For example:
integer*4 val1
character*3 chr1
character*3 chr2
character*10 ans
val1 = 1
chr1 = 'LST'
write(chr2,*) val1
ans = val1 // chr2 !gives me LST 1
!what I want is:
! LST001
Any help would, as always, be greatly appreciated.
I am constructing a entity name in and I need to construct the name from strings and integers. This I know how to do, but I don't know how to get the leading zeros. For example:
integer*4 val1
character*3 chr1
character*3 chr2
character*10 ans
val1 = 1
chr1 = 'LST'
write(chr2,*) val1
ans = val1 // chr2 !gives me LST 1
!what I want is:
! LST001
Any help would, as always, be greatly appreciated.





RE: How to write an integer value into a string with leading zeros?
WRITE (ans, '(a, i3.3)') chr1, val1
RE: How to write an integer value into a string with leading zeros?
Thanks a ton!!!!!
mjs84
RE: How to write an integer value into a string with leading zeros?