SwitchToSongByIndex

Hi, in this code segment I get an error when I move from one song to another.

Var CCValue :Integer
Var Status : Boolean

On ControlChangeEvent (c : ControlChangeMessage) Matching 14 From SongSelect
    CloseLogWindow()
    CCValue = GetCCValue(c)
    SwitchToSetlistView()
    Print("Song Select Song " + CCValue)
    Status =  SwitchToSongByIndex(CCValue, 0)
    if Status == False then
       
    OpenLogWindow()
        Print("Cannot Switch to Song " + CCValue)
    End
End

Here is the error. What am I doing wrong? I don’t see a way to switch songs without adding variation as a parameter.

Switching variations only allowed in rackspace mode: Song2-Intro

SteveC

Ah I found the problem. It was in a separate script in that would select a specific variation when the rackspace changed See below where it shows ************

// For Rackspace switching
On Activate
    byte1=GetCurrentRackspaceIndex()
    oldIndex = byte1
    byte2=0x7f
    m = MakeMidiMessage3(byte0,byte1,byte2)
//   Print(MidiOutDeviceExists(MyController))
    if MidiOutDeviceExists(MyController) then SendNowToMidiOutDevice(MyController, m) End
  byte1 = GetCurrentVariation()+8
// Added the line below to fix the problem ***********************************
  if InSetListMode == False then  SetVariation(GetCurrentVariation()) End
  // Print("Sending Variation Note " + byte1)
End

On deactivate
    byte1=oldIndex
    // Print("oldIndex =" + byte1)
    byte2=0
   // SetVariation(GetCurrentVariation())
    m = MakeMidiMessage3(byte0,byte1,byte2)
    if MidiOutDeviceExists(MyController) then SendNowToMidiOutDevice(MyController, m) End
End

Recommended best practice

If not InSetListMode() then …

It is never necessary to compare a Boolean expression with a Boolean constant and it’s generally easier to read. And unless one is using an optimizing compiler, evaluation will be slightly faster.

Thanks, @dhj !

Except the case is wrong.

InSetlistMode instead of InSetListMode

Ok…. But I just copied it directly from your earlier example and that’s how it was written.

My focus was on how to test a Boolean expression, not the specific expression you used.

1 Like

:rofl:
Garbage in Garbage out I guess

1 Like