Script to edit another script

Hi guys,

How do you edit a script from another script, without copy/paste the whole source ?
For example, in the script below how could I change the value from +1 to +5 or whatever from another script?

\n\t:if ($PingFailCountISP2 < ($FailTreshold+2)) do={\r
\n\t\t:set PingFailCountISP2 ($PingFailCountISP2 + 1)\r


Sorry if this was asked before :slight_smile:

Put the “value to be added” in a :global variable and change that from the other script.

Thank you, that would definitely work. I wish that a more ‘elegant’ approach would exist..like ->set-find-where-something-replace but whatever works :slight_smile:

Well, I consider a global variable more elegant for the purpose that you mention than modifying the code… but to each his own.
It could be possible to get the script source in a variable (when it fits), modify something, and then re-install it, but you have to know that all scripts are “compiled” by the router, and for each change you make they have to be re-compiled.
So unless this was only an example for a more drastic change you really wanted to make, I would go for the standard practice of using variables instead of constants when their value has to be changed.
(in fact I use them even for values that are usually constant but that appear in the code multiple times, and all of them have to be the same)