FIX: Intrinsic Functions in Substring Evaluation Fail

ID: Q43068

4.00 4.01 4.10 5.00 5.10 | 4.10 5.00 5.10

MS-DOS                   | OS/2
kbtool kbfixlist kbbuglist kberrmsg

The information in this article applies to:

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 reference words: 4.00 4.01 4.10 5.00 5.10 KBCategory: kbtool kbfixlist kbbuglist kberrmsg KBSubcategory: FLIss Solution Type : kbfix

Last Reviewed: April 30, 1998