My first script, why no workey?

I done some scripting before, iv read the documentation, once i have my head working around the basics (syntax stuff) I can get stuff done.

I wish to make a toggle (binded to a key) for switching between pattern edit and mixer view.
This is what I have so far, but even this doesn’t work:

local function switch()  
rw = renoise.app().window  
if rw.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR then  
 rw.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_MIXER  
  
  
end  
  
-- MIDDLE_FRAME_MIXER  
-- keys  
renoise.tool():add_keybinding {  
 name = "Global:View:dunks1980",  
 invoke = switch  
}  
  
-- auto reload  
_AUTO_RELOAD_DEBUG = function()  
end  

Forget that I sussed it out.

For the benefit of others who may read this, what was the problem? A misplaced “end”?

It was coming up with:

main.lua:6: ‘then’ expected near ‘=’

not a misplaced “end”

I just removed the line ```
if rw.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR then

Hmm, ok. Well I only mentioned it because I noticed there’s an end missing from your switch() function. You need an end after the if/then statement, and a final end to close out the function.

Also need to use == when doing a comparison on the frame, rather than = which is assigning a new value to it.

This modified function works:

local function switch()  
  
 local rw = renoise.app().window  
  
 if rw.active_middle_frame == renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR then  
 rw.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_MIXER  
 end  
  
end  

Ah, ok thanks. ;)