Page 1 of 1

How to write a script and do its debug

Posted: Fri Aug 02, 2019 10:17 am
by leon84
Is there an external tool that help in script writing? When I use directly winbox I don't have any debug method. I must insert some log output to check for example variables content. If there is a syntax error the script doesn't run but I don't know where is the problem.

Thanks in advance

Re: How to write a script and do its debug

Posted: Fri Aug 02, 2019 11:53 am
by Reinis
Is there an external tool that help in script writing? When I use directly winbox I don't have any debug method. I must insert some log output to check for example variables content. If there is a syntax error the script doesn't run but I don't know where is the problem.

Thanks in advance
For debugging you are doing it correctly by using "output" commands in order to see if the variable contains the desired value.
Regarding syntax errors, you can edit scripts via CLI with "/system script edit MyScriptName value-name=source". Whenever you see text red, syntax is wrong. Press F5 to update the syntax check.
Otherwise, you can use "/system script print" and it will output the scripts with the syntax highlighter and the same rule applies -> red text has errors.

Re: How to write a script and do its debug

Posted: Fri Aug 02, 2019 12:28 pm
by Jotne
I do put the script in curly brackets {} and cut past it to the terminal.
This way it runs as you should run it from the script option.
Also I do use a lot of :put to see what is going on with the variables.

Re: How to write a script and do its debug

Posted: Fri Aug 02, 2019 12:38 pm
by leon84
Thanks a lot!