Registration Count not working with use of variable reference

Hello,
Tweaking one of my scripts to include total wireless registration count and running count as it loops through the entire list for action. Running into an issue where referencing the interface name as a variable returns no results, while explicitly referencing it returns the proper results. Can’t seem to figure out why.

######The following DOES work:######
:local totalWirelessInt
#Set total wireless registrations
:set totalWirelessInt [/interface wireless registration-table print count-only where name=wlan1];
:log warning message= ("Total Wireless Clients of Radio: " . $totalWirelessInt)


######The following DOES NOT work:######
:local wirelessNAME;
:set wirelessNAME "wlan1";
:local totalWirelessInt
#Set total wireless registrations
:set totalWirelessInt [/interface wireless registration-table print count-only where name=$wirelessNAME];
:log warning message= ("Total Wireless Clients of Radio: " . $totalWirelessInt)

Thanks for your help!

You have omitted RouterOS version, as usual.

Work???
Sure???
On registration-table do not exist “name” field, but only “interface” for wlan1. (“radio-name” is the description, if provided, of the remote wlan)

Using correct syntax and logic… is advised…

example 1

{
/interface wireless registration-table
:local totalWirelessInt [:len [find where interface=“wlan1”]]
:log info “Total Wireless Clients of Radio: $totalWirelessInt”
}

example 2

{
:local wirelessNAME “wlan1”
/interface wireless registration-table
:local totalWirelessInt [:len [find where interface=$wirelessNAME]]
:log info “Total Wireless Clients of $wirelessNAME: $totalWirelessInt”
}

Thanks for your help, that’s the advice I needed.

Cheers!