Can i create a table for an if situation?

hi, i’m trying to tweak my script that switches between automation and trackdsps.
i’ve just added an if clause there where it’s like “if you’re in sample editor, switch to pattern editor”.
but there are multiple middle_frame situations that would require me to switch to pattern editor, just so that the lower frame can be displayed.
they are:

renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PHRASE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_KEYZONES
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EFFECTS
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PLUGIN_EDITOR
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR

now, instead of creating an if clause for all of these by hand, would it not be possible to go “if you’re in any of these ones, do x, otherwise do nothing and proceed with the script”?

i.e. “for if u r in 1…7 then do x” ? and have it be a list or an array or whatever the fancy kids call these nowadays.

i mean, is there a more aesthetically pleasing way than just hard-hammering

  local w=renoise.app().window
  local raw=renoise.ApplicationWindow
  local wamf = renoise.app().window.active_middle_frame
  if (wamf==raw.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_PHRASE_EDITOR)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_SAMPLE_KEYZONES)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EFFECTS)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_PLUGIN_EDITOR)
 or (wamf==raw.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR) 
  then renoise.app().window.active_middle_frame=1 else end

?

You could set up a bitop/flag system that would be very reusable and flexible. It’s likely what the big C boys might wanna do, but it’s maybe not the most practical answer if you don’t wanna spend some time learning a bit of programming/engineering.

Most practical answer depends on cases and logic needed. I wouldn’t bother with the aesthetics. Making it “nice looking” takes too much work. (Code above can be shortened by using values instead of constants, but this doesn’t seem advisable in principle with regards to auto-upgrading of tools).

1 Like