Before I describe how to make the script do what you want, there are two concepts to understand, the notion of scope and the notion of focus.
When you push a button on a MIDI footswitch, or click something in the UI, it creates an action. An action is a little data object containing information about what you want to do, other applications might call this a command or a message. Deep inside Mobius are various internal components that can receive these actions and respond to them, the most obvious one of those is a track. In the default configuration there are 8 tracks so when you send down an action you need to include the number of the track you want to handle it. This is called the action scope. For now just think of the action scope as the track number.
You can set the action scope in two ways, either explicitly or through focus. An explicit action scope is what you are setting when you create a binding and you tell it which track number to send it to. This is the binding field that used to be labeled "Scope" but which is now labeled "Send To". When you create a binding with the scope set, it will only be sent to that one specific track.
No one wants to create 8 different bindings for every function they want to use, so most bindings do not specify a scope. So when you press that MIDI switch, we have to decide which track is going to receive the action, that is done by sending it to the track that currently has focus. Think of it like how keyboard focus works with computer application windows. You can have several windows visible on the screen, but only one of them can receive events from the keyboard. The window that receives the keyboard events is said to have focus and is usually highlighted in some way.
If you want a different window to have keyboard focus, you click on it, or bring it to the front, and now the keys go to that window.
In Mobius the focused track is the one with the white box drawn around it. You can change the focused track in several ways: by clicking on it, by using the left/right arrow keys or by binding a MIDI switch to the functions NextTrack, PrevTrack, or SelectTrack. As I mentioned in a different thread, those three functions are not processed by the internal looping components, they are intercepted by the UI and cause the white box to move around. Is similar to how using the Alt-Tab key on Windows (Command-Tab on Mac) brings different windows to the front. Those windows aren't receiving the Alt-Tab key, it is intercepted by the OS and used to juggle the window focus.
So what does all this mean for scripts?
A script can use both methods of sending an action to a track. When you type a function name in a script, say "Record" that function will by default be sent to whatever track currently has focus.
// send the Record action to the focused track
Record
This creates a Record action in much the same way a MIDI binding would create an action. This action has no scope
so the action will be sent to the focused track. In order to set the action scope in a script you use the in statement:
// send the Record action to track number 3
in 3 Record
Note that when you use in it does not change the focused track. It's the same as when you specify a track in a MIDI binding, the action goes directly to that track, it doesn't care which track has focus, and the white focus box doesn't move.
The second way to send a function to a specific track in a script is to change the focus before you send it.
You do that with the three track seletion functions I mentioned earlier.
// change focus to track number 3
SelectTrack(3)
// send Record to the focused track
Record
The difference between the two is that the second one permanently changes track focus. There are other differences that I won't get into here related to some obscure before/after actions that can be configured whenever you change focus.
The main thing to remember, is if you want to send an action to a track but leave the current track focused for future actions use in and if you want to change the focused track so it starts receiving all unscoped actions from anywhere in the future, use SelectTrack.