Use global variable that already exists in another script

Guys, I have this global variable in another script and I would like to use it in another script, how would it be?


:global stopRouterRun false

:do {
             

           :delay 60
} while=(!$stopRouterRun)

EL DONCITO.

This is in the docs, https://help.mikrotik.com/docs/display/ROS/Scripting#Scripting-Variables:

Every variable, except for built-in RouterOS variables, must be declared before usage by local or global keywords. Undefined variables will be marked as undefined and will result in a compilation error.

So if stopRouterRun in your case was defined and assigned as value like “false” elsewhere. You can just remove the assignment in your code above:

:global stopRouterRun
:do {
           :delay 60
} while=(!$stopRouterRun)

@eldoncito2019, it seems like you’re re-inventing the wheel, and posting with a question as your attaching each spoke.

There are few script libraries people have written that have a lot of useful “helper functions”. You can search the forum for most scripting needs and someone likely already has written a script that can adapted. There are quite a few on GitHub, like https://github.com/eworm-de/routeros-scripts and https://github.com/merlinthemagic/MTM-RouterOS-Scripting that may give you ideas, or may be a better place to start than a blank canvas script.

Thanks for your help Amm0, I already solved my problem



:global stopRouterRun
:put $stopRouterRun 

:do {
      
      
      
      :delay 60
} while=(!$stopRouterRun)



EL DONCITO