Topic: SF 2.9 FILE OUTLINE HIGHLIGHT ERROR

Hi Jeff,

The SF 2.9 File Outline process does not appear to highlight the correct Function in certain instances.

For example, when selecting the function 'ch_is_control'  in a file containing several functions and subroutines,

function ch_is_control ( c )
.
.
end function ch_is_control

the following subroutine is incorrectly highlighted instead,

subroutine s_control_blank ( s )
.
.
end subroutine s_control_blank

SF's highlight search routine appears to identify the letters 's_control' which exists within both routine names and not 'ch_is_control' itself.

Frank

Re: SF 2.9 FILE OUTLINE HIGHLIGHT ERROR

Frank,

The highlight search routine isn't using a simple search, so I don't think the similarity in procedure names is causing the issue.   That said, would you mind emailing me the offending source file so I can attempt to determine what exactly is occurring?  The names alone aren't enough to determine what is occurring.

Jeff Armstrong
Approximatrix, LLC

Re: SF 2.9 FILE OUTLINE HIGHLIGHT ERROR

Jeff,

Something peculiar is occurring in this code.  Any changes in the code corrects the error encountered when using the file outline highlight search.  The code below however, reproducibly highlights the incorrect routine on my PC using SF 2.9.  Oddly, removing comments or adding comments seems to correct the problem.

Frank

!*********************************************************************72
      subroutine s_control_blank ( s )
!*********************************************************************72
!
      implicit none

      logical ch_is_control
      integer i
      character*(*) s
      integer s_len_trim
      integer s_length

      s_length = s_len_trim ( s )

      do i = 1, s_length
        if ( ch_is_control ( s(i:i) ) ) then
          s(i:i) = ' '
        end if
      end do

      return
      end !subroutine s_control_blank

!*********************************************************************72
      function ch_is_control ( c )
!*********************************************************************72
!
!  Parameters:
!    Input, character C, the character to be tested.
!
!    Output, logical CH_IS_CONTROL, TRUE if C is a control character, and
!    FALSE otherwise.
!
      implicit none

      character c
      logical ch_is_control

      if ( ichar ( c ) <= 31 .or. ichar ( c ) >= 127 ) then
          ch_is_control = .true.
      else
          ch_is_control = .false.
      end if

      return
      end !function ch_is_control

Re: SF 2.9 FILE OUTLINE HIGHLIGHT ERROR

Frank,

As with all "good" bugs, I can't seem to reproduce this yet.  Using the code you posted, I was able to get the right highlight in the File Outline panel regardless of comments  or spacing or mode (fixed- or free-format).  I'll try it on a few other systems to see if I can get the problem to occur.

One detail that certainly will help the outline highlighting is to explicitly end procedures.  For example, your closing line for your function is:

 end !function ch_is_control

However, it would be perfectly valid Fortran to label the end statement with the procedure type and name:

 end function ch_is_control

When the internal parser in Simply Fortran sees the labeled end statement, it reliably detects the function's closing line.  Otherwise, it may occasionally become confused while detecting a procedure's closing line.

The above is, of course, a Simply-Fortran-specific tip.  Ideally, Simply Fortran would be somewhat better at detecting procedures' closing statements.

Jeff Armstrong
Approximatrix, LLC

Re: SF 2.9 FILE OUTLINE HIGHLIGHT ERROR

Jeff,

You are correct that explicitly naming the END of procedures (e.g., END SUBROUTINE NAME, END FUNCTION NAME) allows the SF File Outline list to highlight the correct procedure.

Perhaps I should have been more specific in my explanation.  SF occasionally 'moves the cursor' to the wrong sub or function procedure when the procedure name in the outline list is 'double clicked'.  On rare occasions as described in previous emails, double clicking one procedure (ch_is_control) causes the cursor to 'jump' and highlight the above procedure ( s_control_blank).

As you clearly stated, explicitly naming the end of procedures eliminates this rare occurrence (not even sure I would call it a bug).

Hope this helps,

Frank