Need Help With Error

I created arpeggiator it works fine but when i start renoise it gives me error pop ups (4 times)
i tryed to check if renoise is nil but this does not work.

i attached error msg

thanks for your help

where the error occurs (see error dialog) you should add an

if (  

check to see if the song has already been created. looks like the script is called before song creation

ok i added this to main function witch calls all other functions

function render()  
if ( then   

but still get errors.

OK the problem seems to be with controls notifiers i use valuebox and i if its values are changes render() function is called so i think when renoise first load script it creates controls and set values to them and then the event is raised before there is object.

When the tool is loaded there is no song, yet:

mytool.lua ->

local bpm = -- error  
-- access the song only in your process functions or the GUI, like for example:  
local do_something_called_from_a_menu_entry()  
 bpm = -> OK  
local do_something_called_from_a_key_binding()  
 bpm = -> OK  

Tools are instantiated only once when the app starts. They are not loaded for every song, so you have to deal with the fact that the song changes while your script is still loaded, and also that there is none when the tool gets instantiated.

If you need want to do something in a tool on a song scope, want to do something for each “new song”, then you can add notifiers to:

-- invoked each time a new document (song) was created or loaded  
 print("a new song was loaded or created, or the initial one was loaded/created")  

tnx mate it solved the problem.

happy coding.