[Fixed 2.6.1] Adding Lists As Properties To Documentnodes

When running:

  
class "SnippetAlias"(rd.DocumentNode)  
 function SnippetAlias:__init()  
 rd.DocumentNode.__init(self)  
 self:add_property("parameter_list", rd.ObservableStringList())  
 end  

I get the following error:

  
std::logic_error: 'invalid, unexpected type for add_property. expected an ObservableBoolean/Number/String object'  
stack traceback:  
 [C]: in function 'add_property'  
 .\prefs.lua:202: in function <.><br>
  [C]: in function 'SnippetAlias'<br>
  .\prefs.lua:37: in function 'init'<br>
  main.lua:15: in main chunk<br>```

<br>
<br>
On the other hand, this seems to work:<br>
<br>

```<br><br>
class "SnippetAlias"(rd.DocumentNode)<br>
  function SnippetAlias:__init()<br>
    rd.DocumentNode.__init(self)<br>
    self:add_property("parameter_list", { "qwer" })<br>
    self.parameter_list:remove(1)<br>
  end<br>```

<br>
<br>
I want an empty StringList to work with, the last snippet runs but it's not nice. Am I missing something?</.>

[quote=“mogue”]
When running:

  
class "SnippetAlias"(rd.DocumentNode)  
 function SnippetAlias:__init()  
 rd.DocumentNode.__init(self)  
 self:add_property("parameter_list", rd.ObservableStringList())  
 end  

I get the following error:

  
std::logic_error: 'invalid, unexpected type for add_property. expected an ObservableBoolean/Number/String object'  
stack traceback:  
 [C]: in function 'add_property'  
 .\prefs.lua:202: in function <.><br>
 [C]: in function 'SnippetAlias'<br>
 .\prefs.lua:37: in function 'init'<br>
 main.lua:15: in main chunk<br>```

<br>
<br>
On the other hand, this seems to work:<br>
<br>

```<br><br>
class "SnippetAlias"(rd.DocumentNode)<br>
 function SnippetAlias:__init()<br>
 rd.DocumentNode.__init(self)<br>
 self:add_property("parameter_list", { "qwer" })<br>
 self.parameter_list:remove(1)<br>
 end<br>```

<br>
<br>
I want an empty StringList to work with, the last snippet runs but it's not nice. Am I missing something?<br>[/quote]<br>
If you attempt to submit some sort of array, it is pretty clear the property-function doesn't support this.<br>
You either have to pick one string from rd.ObservableStringList() and send it to the property. <br>
Do an iterative process with upcounter to add them all.<br>
<br>
I'm just doing something out of the back of my head here, i doubt the below snippet works directly out of the box (since i can't tell what rd.ObservableStringList() actually returns and in what way), but you hopefully get the idea of the direction i'm trying to point you to:<br>
<br>

```<br><br>
for i = 1, #rd.ObservableStringList() do<br>
 local fetched_list_item = rd.ObservableStringList(i)<br>
 self:add_property("parameter_list", { fetched_list_item })<br>
end<br>
<br>```

</.>

Good point! But I’m not trying to do anything so complicated. I just want a clean, empty ObservableStringList() as a property of a class to add to.

Here’s an example (not added to a class) that works:

  
 local list = rd.ObservableStringList()  
 list:insert("asdf")  
 renoise.app():show_error(list[1].value)  

I want to do this but using self:add_property.

Ooops. This should work. Will fix this for the next Renoise update.

For now please use the ugly

self:add_property(“parameter_list”, { “” })
self.parameter_list:remove(1)

workaround.