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

.



Relevant Pages

  • Re: How to detect NULL input?
    ... CHARACTERfname ... CHARACTER(*) evaluateinput ... implicit none characterstr1 ... characterstring string = 'world' if (str1 .EQ. ...
    (comp.lang.fortran)
  • Re: SQL issue?
    ... Here is how you do it from the format of the data you have provided ... Look for the First _ character from the left of the string. ... > I have column FName of varchar type. ...
    (microsoft.public.sqlserver.dts)
  • Re: How to detect NULL input?
    ... That worked for the string comparison with everything except NULL. ... C CHARACTERfname ... C CHARACTER(*) evaluateinput ...
    (comp.lang.fortran)
  • Re: How to detect NULL input?
    ... >>>That worked for the string comparison with everything except NULL. ... CHARACTERfname ... CHARACTER(*) evaluateinput ... >> You need to replace the END program statement by a CONTAINS ...
    (comp.lang.fortran)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)