Article ID: 43068
Article Last Modified on 12/1/2003
APPLIES TO
- Microsoft FORTRAN Compiler 4.0
- Microsoft FORTRAN Compiler 4.01
- Microsoft FORTRAN Compiler 4.1
- Microsoft FORTRAN Compiler 5.0
- Microsoft FORTRAN Compiler 5.1
- Microsoft FORTRAN Compiler 4.1
- Microsoft FORTRAN Compiler 5.0
- Microsoft FORTRAN Compiler 5.1
This article was previously published under Q43068
SYMPTOMS
An application developed in Microsoft FORTRAN that uses a complicated expression that involves intrinsic functions to calculate substring indexes generates incorrect results.
RESOLUTION
Simplify the expression used to specify the substring index by using one or more temporary variables to store intermediate results of the computation.
STATUS
Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.01, 4.1, 5.0 and 5.1 for MS-DOS and versions 4.1, 5.0, and 5.1 for OS/2. This problem was corrected in FORTRAN PowerStation.
MORE INFORMATION
The following program writes the string "B" to the display instead of the correct string "BCDEF."
Sample Code
C Compiler options required: None CHARACTER *20 A, B B = 'ABCDEFGHIJKLMNOP' I = 2 J = 6 A = B(I:(I + IDIM(J, 2))) WRITE(*,*) A END
The following code demonstrates one solution to the problem.
Sample Code
C Compiler options required: None PROGRAM STRING CHARACTER *20 A, B B='ABCDEFGHIJKLMNOP' I = 2 J = 6 K = I + IDIM(J, 2) A = B(I:K) WRITE(*,*) A END
Additional query words: 4.00 4.01 4.10 5.00 5.10
Keywords: kbfix KB43068