Exodia
1
Hello,
I am learning to write some scripts.
I try to convert a decimal number, the version of the os into an integer
So I use:
/system package update get installed-version
that gives me an output of 6.42.2 for e.g.
Can I convert it into an integer to make some compares?
Jotne
2
This loops trough the string and remove all the dots, then convert it to a number.
{
:local version [/system package update get installed-version]
:local numVersion
:for i from=0 to=([:len $version]-1) do={
:local tmp [:pick $version $i]
:if ($tmp !=".") do={
:set numVersion "$numVersion$tmp"
}
}
:set numVersion [:tonum $numVersion]
:put $numVersion
}
Try cut and past this to command line to see the result.
Based on script found here:
http://forum.mikrotik.com/t/help-remove-spaces-form-the-names-in-queue-simple/28735/1