$name function

Help
2007-01-26
2012-12-29
  • George James

    George James - 2007-01-26

    There is probably a bug here somewhere.

    In the first instance of the following example $d(@g) returns 0 (incorrect) in the second instance it returns 1 (correct):

    GTM>zwr ^foo
    ^foo("38706680223112170215796311156433")=""
    GTM>s x=$o(^foo(""))
    GTM>w x
    38706680223112170215796311156433
    GTM>s g=$name(^foo(x))
    GTM>w g
    ^foo(38706680223112170215796311156433)
    GTM>w $d(@g)
    0

    GTM>s x="38706680223112170215796311156433"
    GTM>s g=$name(^foo(x))
    GTM>w g
    ^foo("38706680223112170215796311156433")
    GTM>w $d(@g)
    1

    GTM>w $zv
    GT.M V5.1-000 Linux x86

    The following tests shed a little bit more light on the problem.

    GTM>f x=1:1:20 k ^foo s ^foo($e(99999999999999999999,1,x))="" s y=$o(^foo("")) s
    z=$name(^foo(y)) w !,x,?10,z,?50,$d(@z)

    1         ^foo(9)                                 1
    2         ^foo(99)                                1
    3         ^foo(999)                               1
    4         ^foo(9999)                              1
    5         ^foo(99999)                             1
    6         ^foo(999999)                            1
    7         ^foo(9999999)                           1
    8         ^foo(99999999)                          1
    9         ^foo(999999999)                         1
    10        ^foo(9999999999)                        1
    11        ^foo(99999999999)                       1
    12        ^foo(999999999999)                      1
    13        ^foo(9999999999999)                     1
    14        ^foo(99999999999999)                    1
    15        ^foo(999999999999999)                   1
    16        ^foo(9999999999999999)                  1
    17        ^foo(99999999999999999)                 1
    18        ^foo(999999999999999999)                1
    19        ^foo(9999999999999999990)               1
    20        ^foo(99999999999999999900)              1
    GTM>f x=1:1:20 k ^foo s ^foo($e("99999999999999999999",1,x))="" s y=$o(^foo(""))
    s z=$name(^foo(y)) w !,x,?10,z,?50,$d(@z)

    1         ^foo(9)                                 1
    2         ^foo(99)                                1
    3         ^foo(999)                               1
    4         ^foo(9999)                              1
    5         ^foo(99999)                             1
    6         ^foo(999999)                            1
    7         ^foo(9999999)                           1
    8         ^foo(99999999)                          1
    9         ^foo(999999999)                         1
    10        ^foo(9999999999)                        1
    11        ^foo(99999999999)                       1
    12        ^foo(999999999999)                      1
    13        ^foo(9999999999999)                     1
    14        ^foo(99999999999999)                    1
    15        ^foo(999999999999999)                   1
    16        ^foo(9999999999999999)                  1
    17        ^foo(99999999999999999)                 1
    18        ^foo(999999999999999999)                1
    19        ^foo(9999999999999999999)               0
    20        ^foo(99999999999999999999)              0
    GTM>

    I think it is a problem with $name but the underlying cause might be more deep rooted.

    Regards
    George
    George James Software
    http://www.georgejames.com

     
    • ivan

      ivan - 2007-01-26

      Hi!

      http://fnfismd.com/NR/rdonlyres/9755B3E3-C60E-4BBD-A8B8-5D402B3B07E2/0/Db_whitep2.pdf

      Page 5:
      Database limits
      Numerics 18 digit precision in the range 10-43 and 10+46

      I think this is the answer for this problem.

      Best regards,
      ivan

       
      • George James

        George James - 2007-01-26

        ivan
        I don't think that is the problem.  Numeric values appear to be handled correctly according to the precision rules.  It is when the value is a string (ie over 18 consecutive digits) that the incorrect behaviour is observed.

        It behaves incorrectly when a value is obtained from a global subscript (eg s x=$o(^foo("")) and that value is a string of over 18 characters all of which are numeric.

        In such a case $name(^foo(x)) returns ^foo(9999999999999999999999) when it should return ^foo("9999999999999999999999").

        George
        http://www.georgejames.com

         
        • James A Self

          James A Self - 2007-01-26

          I agree with George that this shows an inconsistency in the behavior of $Name. It appears that numbers longer than the 18 character precision limit are correctly treated as strings by the Set command and by ZWrite and $Order but inconsistently by $Name.

          > s num="12345678901234567890123" zwr num

          num="12345678901234567890123"

          > s test(num)="string subscript",test(+num)="canonic number" zwr test

          test(12345678901234567800000)="canonic number"
          test("12345678901234567890123")="string subscript"

          > s g=$name(test(num)) w g,!,@g

          test("12345678901234567890123")
          string subscript

          > s num="" f i=1:1:10 s num=$o(test(num),-1) q:num=""  s g=$name(test(num)) w ! zwr num,test(num),g,@g

          num="12345678901234567890123"
          test("12345678901234567890123")="string subscript"
          g="test(12345678901234567890123)"
          test(12345678901234567800000)="canonic number"

          num=12345678901234567800000
          test(12345678901234567800000)="canonic number"
          g="test(12345678901234567800000)"
          test(12345678901234567800000)="canonic number"

           
          • Steven Estes

            Steven Estes - 2007-02-20

            Thanks for reporting these issues folks. We will be looking at fixing them in a future release.

             

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks