Community discussions

MikroTik App
 
DeCr0pt
just joined
Topic Author
Posts: 12
Joined: Wed Aug 02, 2017 1:21 pm

Variable in Variable Mikrotik

Wed Aug 02, 2017 1:27 pm

Please sorry for my english i m not native english speaker.

Hello, i m trying to make a program what will check my bgp peers, i have set global variables (example 1 = 1 , 2 = 0) and i want make if with foreach. Simple i want make something like a "Variable what will call variable and display value of variable" in php is this named "Variable variables" and i can done it via $$variable-name. Is this possible in MikroTik?



Thanks for any help
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7169
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 1:31 pm

Not possible.
 
DeCr0pt
just joined
Topic Author
Posts: 12
Joined: Wed Aug 02, 2017 1:21 pm

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 1:32 pm

And is possible to get a variable directly from /system script enviroment? Example via get? I tried it but i got empty responde
 
pe1chl
Forum Guru
Forum Guru
Posts: 10511
Joined: Mon Jun 08, 2015 12:09 pm

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 2:08 pm

You should use an array for this. You can loop across an array using foreach. An array index can be a string.
:global ArrayName;

:set ($Arrayname->"value1") 1;
 
DeCr0pt
just joined
Topic Author
Posts: 12
Joined: Wed Aug 02, 2017 1:21 pm

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 2:57 pm

You should use an array for this. You can loop across an array using foreach. An array index can be a string.
:global ArrayName;

:set ($Arrayname->"value1") 1;
Thanks man, i will try it
 
DeCr0pt
just joined
Topic Author
Posts: 12
Joined: Wed Aug 02, 2017 1:21 pm

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 3:19 pm

Array seems to work but how can i made example this? ($array->"$forVariable") 1; This got empty or very strange output
 
pe1chl
Forum Guru
Forum Guru
Posts: 10511
Joined: Mon Jun 08, 2015 12:09 pm

Re: Variable in Variable Mikrotik

Wed Aug 02, 2017 3:36 pm

In that case the variable must not be in quotes! ($array->$forvariable)
The evaluation of expressions in the scripting language is weird...

Who is online

Users browsing this forum: No registered users and 8 guests