Add the total output

Hello, anyone who can help me with my script. I want to add all the output total from my script.




/ip hotspot
:foreach i in=[user find where name!="admin" and name!="default-trial" and disabled=no and comment!=" "] do={
    :local aUsrcomm [user get $i comment]
    :local aUsrcomm [:toarray $aUsrcomm];
    :local itotal [:tonum ($aUsrcomm->1)];
  
    :log info $itotal;
}

the output is
5
5
5
5
5

the output should be 25.
Screenshot 2023-12-26 2044654304.png

Do you know what a variable is and what the + sign means?

Since I can not work on your machine and I do not have your settings, this is untested.
{
/ip hotspot user

:local tmp “”
:local tot 0

:foreach i in=[find where name!=“admin” and name!=“default-trial” and disabled=no and comment!=" "] do={
:set tmp [:toarray [get $i comment] ]
:set tot ($tot + [:tonum ($tmp->1) ] )
}

:log info “Total is $tot”
}

sorry i don’t know the syntax.

your script working. @rextended thank you very much for your very fast respond. :smiley: