Re: How to detect NULL input?



Are you really using an F77 compiler, or is it a more recent one, but with F77 code?

F77 doesn't have null strings, but F90 does. I'm not sure what happens if you compare against one - I'm slightly surprised it gets past an F77 compiler.

What happens if you initialise fname to ' ' and then test against ' ' ( a space)? I'm wondering if it's currently filled with random junk and pressing return alone doesn't alter it.

Catherine.

jane.sync@xxxxxxxxx wrote:
That worked for the string comparison with everything except NULL.
Maybe I goofed something up in the main. The whole program is below.
Did I goof something up?

      program test
      implicit none
      CHARACTER(12)  fname
      CHARACTER(12)  evaluateinput
C      CHARACTER(*)  fname
C      CHARACTER(*)  evaluateinput

  100 WRITE (*, 101)
101   format  ('String:  ', $ )
      READ  (*, *) fname
      print *, 'Test ',evaluateinput(fname)
      END program

      function evaluateinput(str1) result(string)
      implicit none
      character(*) str1
      character(*) string
      string = 'world'
      if (str1 .EQ. '') then
        string = 'equal'
      else
        string = 'not equal'
      end if
      return
      end

.