- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
I'm converting some old Fortran code and need toadd some leading zeroes to a character string. What I need to accomplish is:
I always need my numer(1-999) to have 3 character digits.
1 should be 001
50 should be 050
999 should be 999
My old code had the following internal write:
write(charNUM,"(B'###')")NUM
IVF doesn't allow this. My solution was to do the following:
IF(NUM.LT.10)THEN
WRITE(CHARNUM,'(I3)')NUM
CHARNUM='00'//TRIM(ADJUSTL(CHARNUM))
ELSE IF(NUM.LT.100)THEN
WRITE(CHARNUM,'(I3)')NUM
CHARNUM='0'//TRIM(ADJUSTL(CHARNUM))
END IF
There must be a cleaner solution than this. Any thoughts?
Thanks,
Ernie P.
I'm converting some old Fortran code and need toadd some leading zeroes to a character string. What I need to accomplish is:
I always need my numer(1-999) to have 3 character digits.
1 should be 001
50 should be 050
999 should be 999
My old code had the following internal write:
write(charNUM,"(B'###')")NUM
IVF doesn't allow this. My solution was to do the following:
IF(NUM.LT.10)THEN
WRITE(CHARNUM,'(I3)')NUM
CHARNUM='00'//TRIM(ADJUSTL(CHARNUM))
ELSE IF(NUM.LT.100)THEN
WRITE(CHARNUM,'(I3)')NUM
CHARNUM='0'//TRIM(ADJUSTL(CHARNUM))
END IF
There must be a cleaner solution than this. Any thoughts?
Thanks,
Ernie P.
1 솔루션
링크가 복사됨
3 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
... and standard conforming, unlike whatever it was you were using (never saw that extension before.)
