Re: converting integer to string without warning

From: Dennis Shea (shea AT XXXXXX)
Date: Fri Aug 15 2003 - 07:29:20 MDT

  • Next message: Sylvia Murphy: "new version of emacs mode available"

    Hello

    A brief test script:

    procedure txt_test(z:string)
    begin
      print ("enter txt_test")
      print (z)
    end
    begin
      i = 1
      txt = new ( (/1/),string)
      txt = i ; <=== no warning
      print (txt)

      txt_test(i) ; <=== this causes the warning message
    end

    ===

    I find these warning messages somewhat of a nuisance in
    production codes also. Unfortunately, there is no
    easy way to stop these messages. Onward ...

    The warning occurs when passing the integer (i) to a
    procedure or function which has the argument prototyped
    as a string.

    I guess the way to avoid the warning is to pass the argument
    as an integer (with or without prototyping) and change the
    type internally.

    procedure txt_test_1(z:integer) ; z prototyped as integer
    begin
      print ("enter txt_test_1")
      zs = " " ; same as zs=new(1,string)
      zs = z
      print(zs)
    end
    procedure txt_test_2(z) ; no prototyping
    begin
      print ("enter txt_test_2")

      if (typeof(z).eq."integer") then
          zs = " " ; same as zs=new(1,string)
          zs = z
      else
         zs = z
      end if
      print(zs)
    end
    begin
      i = 1
      txt = new ( (/1/),string) ; also txt=" "
      txt = i ; <=== no warning
      print (txt)

      txt_test_1(i)
      txt_test_2(i)
    end

    On Fri, 15 Aug 2003, Heiko Klein wrote:

    > Hi,
    >
    > I want to have some integer values as string (for printing ...). The
    > automatic coercion works, but throws allways a warning like:
    >
    > 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
    >
    > (for example on:
    > i = 1
    > txt = new ( (/ 1 /), string)
    > txt = i
    > )
    >
    > Is there a cast-function or operator, which should be used instead of
    > automatic coercion. Or does there exists another possibilitiy to disable
    > the warnings for production code.
    >
    > Regards,
    >
    > Heiko
    >
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Fri Aug 15 2003 - 07:55:33 MDT