Colorize scripting

Hi,
I think it would be very useful if inside Winbox, where a box permit to enter some scripting code, it would be colorized and with line numbers as in the terminal window.
I often need to modify and debug scripts inside winbox and colors help.
Please, Mikrotik Team, consider to inplement this function that many unoffcial editors have, not your official… :wink:

That would help debugging and creating script, so +1

I SINCERELY think it’s completely useless right now, for two reasons,
first of all the staff should be dedicated to FEATURE EQUALIZATION between RouterOS 7 and previous versions.

Subsequently it would only be an embellishment, and in any case everyone would like it similar to the one they use the most, and it’s quicker if everyone uses their own favorite directly.

A generic check can already be had with
“/system scheduler print detail”
or
“/system script print detail”
(adding or not “where name=<SCRIPT_OR_SCHEDULER_NAME>”)

Interesting.

Rex, what external editor do you use for the scripts? I’m trying Visual Studio Code and it works fine.

Is there a better one?

BR.

Notepad…
yes, the Windows Notepad… not notepad+… and HomeSite+ 5.5…

About the better editor, I never use something more complex for scripting.

I think that how to manage and load Mikrotik staff is out of our business. Firmware staff could be different from winbox staff, so nobody subtracts time to nobody.

Subsequently it would only be an embellishment, and in any case everyone would like it similar to the one they use the most, and it's quicker if everyone uses their own favorite directly

Your preferred editor cannot run RouterOS code. So it's not the same. Do you ever wrote a complex huge script?

If colorize the script editor is useless, why is the terminal colorized?

I think that how to manage and load Mikrotik staff is out of our business. Firmware staff could be different from winbox staff, so nobody subtracts time to nobody.

Subsequently it would only be an embellishment, and in any case everyone would like it similar to the one they use the most, and it's quicker if everyone uses their own favorite directly

Your preferred editor cannot run RouterOS code. So it's not the same. Do you ever wrote a complex huge script?

If colorize the script editor is useless, why is the terminal colorized?

so, this topic, what does it exist for?


If winbox is to execute the RouterOS code ( «cannot run RouterOS code» ), surely it also needs to interact with other parts, not just the “nice” script editor,
so that already belies the fact that “it only takes one person”,
then there are dozens of things that winbox (and also webfig) that they don’t do and that are only available via CLI,
so it’s better if, as already written, they finish before developing what they have to do to make winbox do everything that is already available.


why, writing an “editor” for winbox would it “compile” and “execute” the script before running inside the routerboard?


well… who knows… just some hundred… ask the others forum members…


For the same reason you can open any topic on this forum and add it to the hundreds of useless topic
about requests made to forum users (instead of staff) that mikrotik personnel will never consider.

Even the scripts give such generic errors that often you don’t understand what’s wrong,
dozens of instructions are absent, like a very stupid “search and replace”,
the floating point numbers are missing,
the time and date is inconsistently written in 4 (and more) different ways,
the conversion functions are trivially missing,
already working function are broken and never repaired (like convert a string to ip-prefix)
directory can not be created
the variables are limited to 4k or 62k (depends on case and context)
missing CP1252 (and the other), UTF-8 and UCS-2 support
and I could continue the list for hundreds of other things,
let alone if they are dedicated to “coloring” the code, as if it were the most important thing to do…

Gotta love the minimalism of notepad. However, I like color coding too! In fact one reason I don’t use the “edit” in the CLI because of that. Personally I end up using with VS Code since it offers both RSC colors and VIM (plus helpful plugins for SSH/SCP, “prettier”, JSON viewer/checker, etc. etc.) – everyone’s different.

AFAIK, RouterOS is “nano” (or some other pico clone), which does support syntax coloring. So this largely involve “translating” the numerous colorizers from vim to VS Code already out there – these “syntax of the syntax” is just some regex that can easily be copied to the specific format required for the “Mikrotik editor”.

See nano’s docs, it’s doesn’t look hard from specs:
https://www.nano-editor.org/dist/latest/nano.html#Syntax-Highlighting
or examples of it:
https://github.com/scopatz/nanorc

Unlike your “offline editor” choice, the one on the RouterOS isn’t something you can change yourself… so don’t think it’s unreasonable request.

I have no idea how MT prioritizes things, or decides new features – feel more random than it should... And, can't imagine this be high on the list either given v7 still has some growing pains.

But if important to you, probably should file a "Feature Request" in JIRA: Log into Atlassian - Support

Likely no greater urgency, but at least tracked likely there main list of these things.

I totally agree. Unfortunately the wisdom of those who are too good to use only notepad (I haven’t used windows for 20 years and unfortunately I can’t experiment with this wonderful technique) do not consider that most of the others are less good than him, and that the tools need to be calibrated for them. This is demonstrated by the fact that all development IDEs use colors and that all developers on the planet use IDEs, not notepad. It would be appropriate to ask what is normal and what is not. But I know the “saccenza” of some Italians, because unfortunately I am part of their people. I won’t give any more answers on this kind of philosophy, because fueling a flame is not why I wrote.

In fact, fueling it no, but starting it yes…
The usual Scandinavian troll.


There you go: you’ve added yourself to the list of Italians to be ashamed of.

Colors? Come on! What will be next? Reporting syntax errors instead of “silent death”? It would ruin the experience!

I’m kidding, of course. But after it being like this for so many years, I do sometimes think that the general unfriendliness of RouterOS scripting might be by design for some reason.

You fail to understand how a company works and that it is divided into departments. You'd be able to accuse the graphics Mikrotik guys of wasting time redoing the logo instead of fixing the firmware. So you started judging and being offensive. I'm the one who's ashamed!

What a silly way to counter by writing “then you’d be able to do this or that”, is worth absolutely nothing.

Maybe someone can tell which tool I can use for formatting?
Because it`s complicated to support code style in notepad, example:

/interface ethernet monitor ether1 once do={
:if ($"rate" != "11Gbps") do={ 
:log error "ether1 is NOT  $"rate""
:local 1Gbit "$error $deviceName%0A$deviceDate $deviceTime : %0A%0Aether1 == $"rate""
$TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=$1Gbit


/interface ethernet set ether1 disabled=yes
:delay 3
/interface ethernet set ether1 disabled=no


:log warning "ether1 is $"rate""

	}

:if ($"status" == "link-ok") do={
:local 1Gbit "$success  $deviceName%0A$deviceDate $deviceTime : %0A%0Aether1 == $"rate""
$TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=$1Gbit
}
}

For highlights at least I can use VScode, but I did not find formatter tool.

I am Java developer and write script on routerOs is really painful, no debugging, syntax highlights, no formatter, just copy/paste by little pieces and execute… I use it really rare, but I don`t understand why no one else bothers it.

Because “no one else” want first “abbelishment” than a long-term v7…

11Gbps ???

Try to write easily and correctly the code, less time…
/interface ethernet
:local if “ether1”
:local mon [monitor $if as-value once]
:local rate ($mon->“rate”)
:local status ($mon->“status”)
:local message “$deviceName%0A$deviceDate $deviceTime : %0A%0A$if = $rate”

11Gbps ???

:if ($rate != “11Gbps”) do={
:log error “$if is NOT $rate”
[$TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=(“$error $message”)]
disable $if
:delay 3s
enable $if
:log warning “$if is $rate”
}

:if ($status = “link-ok”) do={
[$TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=(“$success $message”)]
}
For test the script on terminal, put all the script between { }

FWIW, on the topic, I believe they add colors to the built-in editor in latest V7 now. At least for “/system/script edit [find] source”. It won’t do syntax coloring using an .rsc file and /file edit contents however.

Yeah there is no formatter plugin. Although, there is “style guide” and many preference.

The only option for debugging is copy script as file to RouterOS, then using “/import verbose=yes”. Dispute the same “import”, it really run code in a file, but offer the verbose=yes option which will show a line-by-line output. This can be helpful to spot parsing errors. No debugger, but helpful sometimes.