Go back 1 song part even through to previous song

// this was part of a much larger script. I have most of the extraneous removed.

On ControlChangeEvent(m : ControlChangeMessage) Matching 1,20,21,22,67,68,96,97,102 from M1

 var
  Incc : integer
  InValue : integer
  cc1 : controlChangeMessage
  CurrentPart : integer
  CurrentSong : Integer
  NumParts : integer
  //Print(m);
  
 Incc = GetCCNumber(m);
 InValue = GetCCValue(m)
 
//my cc for going back is 68
 If Incc == 68 then
If InValue>0 then
//is it the first song part?
 CurrentPart=GetCurrentSongPart()
 //Print (CurrentPart);
 If CurrentPart>0 then
// not the first song part so we just go back 1 song part
 SongPrevPart()
  elsif CurrentPart==0 then // going to previous song
//it is the first song part so we have to go back a song  
CurrentSong=GetCurrentSongIndex()
  if CurrentSong>0 then // not the first song
  PrevSong() // go to previous song
  NumParts=GetSongPartCount()// how many song parts
  //Print (NumParts);
  SetSongPart(NumParts-1)// set to last song part
  end
 end
end
End

Please remember to put triple backquotes before and after your script so that it’s more easily readable. I have edited your post accordingly

Thank you for sharing this - just the functionality I am looking for. I am a newbie with scripts so can you let me know when I put the script in the wiring screen?

Thanks

I put this in the rackspace script on each rackspace- but I wonder if it would work as a global script and save having to paste it in each rackspace.

I’m not in from of my computer so I don’t recall the exact language, but would this be the same thing as unchecking the “stay within rackspace/song for next/previous“?

The problem with that mechanism as currently implemented is that when you don’t stay within the rackspace/song, and the “Prev” command takes you to the previous rackspace or song, it positions you at the FIRST variation/song part, rather than the last one.

I’m wondering whether that should be an “advanced” option so it can be changed

Oh right! That makes sense!