Announcement

Collapse
No announcement yet.

User defined NVParams: Behavior of load and save strings and integers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • User defined NVParams: Behavior of load and save strings and integers

    I am trying to use NvParams 128 - 254. I have a function to read the parameters and a function to store a value.

    Code:
    def setParam(param, val):
    saveNvParam(param, val)
    def readParam(param):
    a = loadNvParam(param)
    rpc(portal, 'logEvent', a)
    setParam(128,'0417181135') displays 0417181135 when I read the parameter.

    The following manipulations gave these results:
    a = loadNvParam(128)
    rpc(portal,'logEvent', a) 0417181135
    rpc(portal,'logEvent', type(a)) 2
    x = a[6:10]
    rpc(portal,'logEvent', x) 1135
    rpc(portal,'logEvent', type(x)) 2
    y = int(x)
    rpc(portal,'logEvent', y) 1135
    rpc(portal, 'logEvent', type(y)) 1
    b = loadNvParam(128)
    b = int(b)
    rpc(portal,'logEvent', b) -20841
    rpc(portal,'logEvent', type(b)) 1

    'a' is a string because I entered it as a string and I am able to slice it. I am also able to convert the slice into an integer.

    Why doesn't 'b' convert to the integer 0417181135 if 'y' converts to integer 1135? Even if I replace the leading zero with a '1' I get 30871.
    If I try to save the integer 0417181135, I get 'An invalid parameter value was entered'.
    If I try to save the integer 417181135, I get 'An error occurred while trying to call the function setParam on node'.


  • #2
    There is no such integer as 0417181135 - in SNAPpy, which only supports 16-bit math.

    In Portal, 0417181135 is going to generate an error anyway, because Python generally treats numbers starting with a zero as octal, in which case the digits 8 or 9 are illegal.

    Comment

    Working...
    X