Assign IP to multiple PPPOE

Hi guys

I need some help with this script. I can select all the users under the active PPPOE connectons, but when trying to assign an IP to them for SSH sessions, it only return 1 IP.
Here is my script I’m using:

:global A;:global B;:global C;:global NAME;global SWAPPED;global NAMES;global IP;

:foreach PPP in=[/ppp active find encoding=“”] do={:set NAME [/ppp active get $PPP name];:set NAME [:pick $NAME 1 [:len $NAME]];:set NAME [:tonum $NAME];:set A ($A , $NAME)}

:set C [:len $A] do={:set SWAPPED (false);:for i from=1 to=($C - 1) do={:if ([:pick $A ($I - 1)] > [:pick $A $I]) do={:set B [:pick $A ($I - 1)];:set A ([:pick $A 0 ($I - 1)], [:pick $A $I], $B, [:
pick $A ($I + 1) [:len $A]]);:set SWAPPED true}};:set C ($C - 1)};

:foreach NUMBER in=[$A] do={:if ([:len $NUMBER] = 1) do={:set NAME (“N000”.$NUMBER)};:if ([:len $NUMBER] = 2) do={:set NAME (“N00”.$NUMBER)};:if ([:len $NUMBER] = 3) do={:set NAME (“N0”.$NUMBER)};:
if ([:len $NUMBER] = 4) do={:set NAME (“N0”.$NUMBER)};:set NAMES ($NAMES , $NAME)}

The top part works. The last command doesn’t select more than 1 IP
:foreach NAME in=[$NAMES] do={:set IP [/ppp active get [find name=$NAME] address]}

Your help is much appreciated.