Ising @if:else to toggle between folder formats

I'm trying to create a hotkey that will set the format to "Group by Kind", (a pre-defined favourite format that uses Leo's Kind_Columns.js script) and back to the folder's default format if already set.

@if:!Set Format="Group by Kind"
Set Format="Group by Kind"
@if:else
Set Format !folder

Line 3 seems to be the problem as all other lines work in isolation. Am I using @if:else wrong?

Set FORMAT isn't a command that can be tested (broadly speaking, you can test commands that change "states", but Set FORMAT is an action command rather than a state command).

Instead, you can test for something specific that setting the format does; e.g., test whether the list is currently grouped by kind:

@if:!Set GROUPBY="scp:Kind Columns/Kind"
Set Format="Group by Kind"
@if:else
Set Format !folder

Thanks for the explanation and the fix Jon, it works perfectly