Sync-Lock macro on or off

Is there a way to call sync-lock via a macro that will either set it on or set it off.

Currently it is a toggle and all you can do is alternate it from what it is. This can be problematic if one doesn’t always start in a the same state.

Only a toggle: Scripting Reference - Audacity Manual

Yes I saw the manual, I was hoping there was a “secret” way, or a trick.

What is the best way to get a feature request like this in? As a programmer this is a strange one. I had a macro that goes super weird based on whether sync lock is set or not. If I could set it to off it would work fine.

There’s a “secret way” to read the current Sync-Lock state, but that’s not really useful for ordinary Macros as ordinary macros don’t have conditionals (Audacity Macros are just a list of commands).

GetPreference: Name="GUI/SyncLockTracks"

However, Nyquist Macros have the full capabilities of a programming language, so you could use a Nyquist Macro to enable Sync-Lock like this:

;type tool
(setf cmd "GetPreference: Name=\"GUI/SyncLockTracks\"")
(when (string= (car (aud-do cmd)) "0")  ;Sync-Lock off
  (aud-do "SyncLock:"))
""  ;return no-op

The above code can be used in a normal Macro by adding a “Nyquist Prompt” command to the Macro, and entering that code as the parameters.