Ankündigung

Einklappen
Keine Ankündigung bisher.

PML kurios

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [Problem] PML kurios

    in AVEVA Catalogue Paragon Mk2.1.0.7 (andere Module bestimmt auch)

    !test = '/TUBE/NN/WEIGHT/0.29'
    !a = !test.split('/').last().real()
    q var !a

    <REAL> 0.29
    !b = !a * 100
    q var !b

    <REAL> 29
    !AR[!b] = !a
    q var !AR

    <ARRAY>
    [28] <REAL> 0.29 $*-------------------> warum 28?

    !AR.delete()

    !b = !b.string().real() $* also, mach aus dem real ein string und dann wieder ein real ( auf sowas kommt man eigentlich nur nach 2 Bier )
    q var !b

    <REAL> 29
    !AR[!b] = !a
    q var !AR

    <ARRAY>
    [29] <REAL> 0.29

  • #2
    !AR[$!b] = !a
    --> solves this issue... reason?... Need more beer!
    Geht net, gibt's net!
    [Entfessler Start]
    Ois wos I do verzapf, is mei eigana Bledsinn und spieglt net die Meinung der Bude wo I hakl (g'haklt hob oder hakl'n werd) wida.
    [Entfessler Ende]

    Kommentar


    • #3
      This really doesn't make sense...

      Paste as Makro:
      Code:
      !AR.delete()
      handle any
      endhandle
      !BR.delete()
      handle any
      endhandle
      
      !test = '/TUBE/NN/WEIGHT/0.29'
      !a = !test.split('/').last().real()
      q var !a
      
      !b = !a * 100
      q var !b
      
      !AR[!b] = !a
      q var !AR
      
      !c = !b.string().real() $* also, mach aus dem real ein string und dann wieder ein real ( auf sowas kommt man eigentlich nur nach 2 Bier  )
      q var !c
      
      !BR[!c] = !a
      q var !BR
      I know ARRAYs are starting with [0] in C#, VB, ... languages, but this doesn't give a reason for the behaviour...

      This is working correct:
      Code:
      !AR.delete()
      handle any
      endhandle
      !BR.delete()
      handle any
      endhandle
      
      !test = '/TUBE/NN/WEIGHT/0.29'
      !a = !test.split('/').last().real()
      q var !a
      
      !b = !a * 100
      q var !b
      
      !AR[$!b] = !a
      q var !AR
      
      !c = !b.string().real() $* also, mach aus dem real ein string und dann wieder ein real ( auf sowas kommt man eigentlich nur nach 2 Bier  )
      q var !c
      
      !BR[!c] = !a
      q var !BR
      Geht net, gibt's net!
      [Entfessler Start]
      Ois wos I do verzapf, is mei eigana Bledsinn und spieglt net die Meinung der Bude wo I hakl (g'haklt hob oder hakl'n werd) wida.
      [Entfessler Ende]

      Kommentar


      • #4
        Servus zusammen,

        das Problem kann eigentlich nur im Konstruktor der Klasse REAL liegen, oder in einer der Überladungen.
        Dieses FEATURE, wie es Herbert nennt, ändert nämlich sein Verhalten
        Code:
        !a = .21
        !y = !a * 100
        !ar[!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
        
        !a = .25
        !y = !a * 100
        !ar[!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
        
        !a = .26
        !y = !a * 100
        !ar[!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
           [26]  <REAL> 30
        
        !a = .29
        !y = !a * 100
        !ar[!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
           [26]  <REAL> 30
           [28]  <REAL> 30
        Oder doch ein BbbbbUG?

        Wenn man den Wert der Variable bei der Zuweisung nimmt, dann klappt es

        Code:
        !a = .21
        !y = !a * 100
        !ar[$!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
        
        !a = .25
        !y = !a * 100
        !ar[$!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
        
        !a = .26
        !y = !a * 100
        !ar[$!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
           [26]  <REAL> 30
        
        !a = .29
        !y = !a * 100
        !ar[$!y] = 30
        q var !ar
        
        <ARRAY>
           [21]  <REAL> 30
           [25]  <REAL> 30
           [26]  <REAL> 30
           [29]  <REAL> 30
        mitn "M" geht's manchmal leichter, aber Winkelbemaßung geht a net

        Kommentar


        • #5
          Hi,

          seems like arr[!x] uses the .INT() method of the REAL OBJECT.
          This works, like descriped in documentation, by rounding down to next INT.
          Which means if your 29 isn’t stored as such, but e.g. as 28.9999999999998 the result will be 28.

          There is another method .NINT() available, which rounds to nearest integer up or down – arr[!x.nint()] will do the job properly.

          INT() REAL Convert to whole number, rounding down.

          NINT() REAL Convert to nearest whole number (up or down).


          Code:
          !x = 28.9999999999998
          q var !x.int()
          <REAL> 28
          q var !x.nint()
          <REAL> 29
          br
          karl

          Kommentar


          • #6
            But, why is it not stored as 29?
            This is the question and I think this is a bug.
            Of course, you have a lot of possibilities to workaround this failture - but you need to know it,

            And thank you all for the interesting answers.
            Peter

            Kommentar


            • #7
              I just had a quite similar case.
              C#.NET (Framework 4.6.2, x64 ConsoleApplication on Visual Studio 2013) behaves exactly the same way...
              0.29 * 100 = 28.999999999999996



              best wishes,
              Karl

              Kommentar

              Lädt...
              X