Can you control the length of the generated string? In ROS 6.XX.

:local num 00 ;
for p from=0 to=99999 do={
/interface pppoe-client set pppoe-out1 comment=(“SNA”.$num+$p)
:delay 2
}
In a script like this, how can the content of the comment be changed to something like SNA00000, SNA00000 1, until SNA0099999. This way? Can’t we just use addition directly, can we only concatenate characters?

:local num 00 ;
is completely useless the ; and the 00 if not inside quotes, because numeric 000000000000000000000000000 is 0
(add “” is useless, if “00” is added to 1, first “00” is converted on a number, and is 0 + 1 = 1 // adding “1” as string to “00” is “001”)

Your script, ignoring errors, change comment on same pppoe-client each 2 seconds on this sequence:
SNA1 / SNA2 / SNA3 … SNA99997 / SNA99998 / SNA99999
It’s not clear what it’s for, you didn’t explain it.

This generates consecutive labels, but does not read the already existing value, to modify it.
{
:local prefix “SNA”
:local numlength 7
:local zeros “”
:local final 1
:local temp “”
:for x from=0 to=($numlength - 1) do={:set final ($final * 10) ; :set zeros “0$zeros”}
:for number from=0 to=($final - 1) do={
:set temp “$zeros$number”
:put (“SNA$[:pick $temp ([:len $temp] - $numlength) [:len $temp]]”)
}
}
If you can ignore the superfluos 00000, and the comment is already SNAxxxxxxxx, you can use it to increase of 1 the counter:
/interface pppoe-client print where [set pppoe-out1 comment=(“SNA$([:pick $comment 3 [:len $comment]] + 1)”)]
This is what you want, if is to add 1 every time the script is launched.
If the comment do not exist or is invalid, the script set it to SNA0000001
{
:local iface “pppoe-out1”
:local prefix “SNA”
:local numlength 7
:local zeros “”
:local final 1
:local temp “”
:for x from=0 to=($numlength - 1) do={:set final ($final * 10) ; :set zeros “0$zeros”}

/interface pppoe-client
:local comment [get $iface comment]
:local number  ([:tonum [:pick $comment [:len $prefix] [:len $comment]]] + 1)
:set temp "$zeros$number"
set $iface comment=("SNA$[:pick $temp ([:len $temp] - $numlength) [:len $temp]]")

}

Oh! Great God~~I may not have described it properly. The character prefix I want to get is SNA00/SNA01/SNA02… SNA09 and then concatenated with complete characters such as SNA000000-SNA009999/SNA100000-SNA0199999/SNA0900000-SNA0999999. The last 5 digits range from 00000 to 99999, with only 100000 range intervals.

Inspired by you, 01-09 has been resolved! But there are still some issues with 00, SNA0000000-SNA0099999