write something to effectcolumn, while in notecolumn or in effectcolum

I’m wondering how to write number_amount and amount_value to the effectcolumn, while in notecolumn (so selected_effect_column_index would be nil), or while in effectcolumn, without shooting nil?

i mean, i got the slider to work really well from both notecolumn and effectcolumn, but for some reason, effect_write is structured differently.

so this works:

vb:minislider{ id="effectslider", width=30,height=127, min=0, max=0xFF, notifier=function(v4) 
local writenc=renoise.song().selected_note_column_index
renoise.song().selected_effect_column_index=1
if renoise.song().selected_effect_column then renoise.song().selected_effect_column.amount_value=v4 end 
renoise.song().selected_note_column_index=writenc
end}

but this doesn’t:

--Effect Functions
function effect_write(effect,status)
local s=renoise.song()
local w=renoise.app().window
--local 
local efc=s.selected_effect_column
local writenc=nil
writenc=renoise.song().selected_note_column_index
local writer=tostring(writenc)
renoise.song().selected_effect_column_index=1

--if s.selected_effect_column_index == nil then
local i=effect
 if efc==nil then
  return
  else
  if efc.number_string==i then
if renoise.song().selected_effect_column then renoise.song().selected_effect_column.number_value=i end 
renoise.song().selected_note_column_index=writenc
-- efc.number_string="00"
-- efc.amount_value=00
   else
  efc.number_string=i
-- efc.amount_value=00
  renoise.app():show_status(status)
 end
  w.active_middle_frame = 1
  w.lock_keyboard_focus = true
-- renoise.song().selected_note_column_index=writer
 end
end

well, here we go, this seems to work - it doesn’t have logic for specific effect commands (like for 0B00, you should only be able to use the slider to set 0B00 or 0B01), but it does work both in effect column and in note column.

function effect_write(effect,status)
local s=renoise.song()
local nc=s.selected_note_column
local ec=s.selected_effect_column
local nci=s.selected_note_column_index
local w=renoise.app().window
if nc == nil then 
-- Protect user if notecolumn is nil
  if ec == nil then return false
-- Also protect user if effect column is nil  
  else 
       s.selected_effect_column.number_string=effect
-- If effectcolumn does exist, just write to it
  renoise.app():show_status(status)

return end end

local writenc=nil
writenc=nci
-- Store current note column index into a local variable

s.selected_effect_column_index=1
-- Set the selection location to effect column index 1

s.selected_effect_column.number_string=effect
-- Write to the amount value of the selected effect column - receive this from effectslider.

s.selected_note_column_index=writenc
-- Return back to previous note column index.

  renoise.app():show_status(status)
  w.active_middle_frame = 1
  w.lock_keyboard_focus = true
s.selected_note_column_index=writenc
 end

well, here we go, this seems to work - it doesn’t have logic for specific effect commands (like for 0B00, you should only be able to use the slider to set 0B00 or 0B01), but it does work both in effect column and in note column.

function effect_write(effect,status)
local s=renoise.song()
local nc=s.selected_note_column
local ec=s.selected_effect_column
local nci=s.selected_note_column_index
local w=renoise.app().window
if nc == nil then 
-- Protect user if notecolumn is nil
if ec == nil then return false
-- Also protect user if effect column is nil  
else 
s.selected_effect_column.number_string=effect
-- If effectcolumn does exist, just write to it
renoise.app():show_status(status)

return end end

local writenc=nil
writenc=nci
-- Store current note column index into a local variable

s.selected_effect_column_index=1
-- Set the selection location to effect column index 1

s.selected_effect_column.number_string=effect
-- Write to the amount value of the selected effect column - receive this from effectslider.

s.selected_note_column_index=writenc
-- Return back to previous note column index.

renoise.app():show_status(status)
w.active_middle_frame = 1
w.lock_keyboard_focus = true
s.selected_note_column_index=writenc
end

I believe that these two lines do not make sense:

local writenc=nil
writenc=nci

Putting a line defining the local is enough:

local writenc = nci

But it is possible to write directly to the effect column that you want, regardless of where the cursor is in the whole pattern editor:

--note: the valid "value" is 1 to 8

function write_effect_column( value )
  local song = renoise.song()
  --show effect column
  song.selected_track.visible_effect_columns = value

  --write effect values to all track type (sequencer/group/master/send) 
  local eff = song.selected_line:effect_column( value )
  eff.number_string = "0B"
  eff.amount_value = 9
end

--test
write_effect_column( 1 )

This function is already “armored” against errors and is more direct.