# ParamNum function for Sysex?

**URL:** <https://forum.electra.one/t/paramnum-function-for-sysex/1341>\
**Category:** Developers\
**Tags:** lua\
**Created:** [February 13, 2022, 1:52pm UTC](https://forum.electra.one/t/paramnum-function-for-sysex/1341 "2022-02-13T13:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewIgnis](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/newignis/32/767_2.png) [@NewIgnis](https://forum.electra.one/u/NewIgnis)\
**Post date:** [February 13, 2022, 1:52pm UTC](https://forum.electra.one/t/paramnum-function-for-sysex/1341/1 "2022-02-13T13:52:17Z")

</div>

Can anyone help me?  
I want to make a standardized Sysex json message I can reuse in almost all SysEx controls of a certain preset. It should make it much faster to build presets.  
The Sysex message should look like this:

```auto
[
  "42",
  {
    "type": "function",
    "name": "getChannelByte"
  },
  "30",
  "41",
  "00",
  {
    "type": "function",
    "name": "getParamNum"
  },
  {
    "type": "value"
  },
  "00"
]

```

The first 5 bytes are typical for a Parameter Change for the Korg 03R/W.  
But it’s the sixth byte I struggle with.  
I’ve made a function looking like this:

```auto
function getParamNum(valueObject) 
    local message = valueObject:getMessage ()
    local paramNum= message:getParameterNumber ()
   return paramNum
end

```

But that doesn’t work. It returns the error “error running function ‘runTemplateFunction’: ctrlv2/p003.lua:21: method ‘getMessage’ is not callable (a nil value)” And the browser and the Electra One hang after this.

---

<div class="post-metadata">

**Author:** ![oldgearguy](https://avatars.discourse-cdn.com/v4/letter/o/f4b2a3/32.png) [@oldgearguy](https://forum.electra.one/u/oldgearguy)\
**Post date:** [February 14, 2022, 10:52am UTC](https://forum.electra.one/t/paramnum-function-for-sysex/1341/2 "2022-02-14T10:52:38Z")

</div>

Don’t you need two parameters? getParamNum(ValueObject, Value) rather than just the one?

I think the missing parameter causes the stack to be messed up and causes the getMessage() call to fail.
