FIX: Intrinsic Functions in Substring Evaluation Fail

ID: Q43068


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1


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 :
Version : :4.0,4.01,4.1,5.0,5.1
Platform :
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.