Trouble with string comparisons

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Wed Apr 24 2013 - 06:27:49 MDT

Hi,

I'm trying to compare some strings in a function:

function chkvName3D(vName:string)

begin

   nme = stringtochar(vName)

   if ( (nme(0:8) .eq. "MEANTAU") .or. \

        (nme(0:6) .eq. "CLDLOW") .or. \

        (nme(0:6) .eq. "CLDMED") .or. \

        (nme(0:6) .eq. "CLDTOT") .or. \

        (nme(0:3) .eq. "Z3") .or. \

        (nme(0:5) .eq. "PREC") .or. \

        (nme(0:3) .eq. "FSN") .or. \

        (nme(0:3) .eq. "FLN") .or. \

        (nme(0:2) .eq. "PS") .or. \

        (nme(0:3) .eq. "SOL") )

      print(nme+" is a 3D variable!")

      return(True)

   else

      return(False)

   end if

end

if the vName = "CLDICE" then I get the error:

warning:Argument 0 of the current function or procedure was coerced to the
appropriate type and thus will not change if the function or procedure
modifies its value
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading nme

I'm struggling to understand why this keeps failing?

What is a good way to compare all of a string or only part of the string?

Thanks,
/M

-- 
Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Apr 24 06:28:00 2013

This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:26 MDT