Sweet, I think I can work with that. Much appreciation!! -- Christopher Tyler MTCRE/MTCNA/MTCTCE/MTCWE Total Highspeed Internet Services 417.851.1107
----- Original Message ----- From: "Scott Reed" <sr...@nwwnet.net> To: "Mikrotik discussions" <mikrotik@mail.butchevans.com> Sent: Monday, March 7, 2016 3:23:41 PM Subject: Re: [Mikrotik] Script to monitor ethernet interface speed Looks like arrays are available. Here is a function to put a value in an array: # Usage: [$arrayPush <$array name> <value> <key position to place value (0-n or -1)>] # Input an array name, value, and the key position to push the value to. To push value to the end of the array, enter -1. # If array doesn't already exist, you must declare the variable and set it to "" before calling the function. :global arrayPush do={ :if ($2="") do={ :error "You did not specify a value to add to the array."; } :if ($1!="" && $3="") do={ :error "You did not specify the key position to place the value in the array."; } :if (($3<(-1)) || (([:typeof $3]!="num") && ([:typeof $3]!="str")) || ($3>([:len $1]-1))) do={ :error "Argument 2 invalid."; } :local string; :if ([:typeof $1]="array" && $3=(-1)) do={ :foreach item in=$1 do={ :set string ($string . "," . $item); } :set string ($string . "," . $2); :set string [:toarray $string]; :return $string; } :if ([:typeof $1]="array" && [:len $1]>="0") do={ :local counter "0"; :foreach item in=$1 do={ :if ($counter!=[:tonum $3]) do={ :set string ($string . "," . $item); :set counter ($counter+1); } else={ :set string ($string . "," . $2); :set string ($string . "," . $item); :set counter ($counter+1); } } :set string [:toarray $string]; :return $string; } :if ($1="") do={ :set string $2; :set string [:toarray $string]; :return $string; } } Here is another one dealing with arrays: http://forum.mikrotik.com/viewtopic.php?t=84464 Might not get you where you are wanting to get, but at least arrays are available so you might get there. On 3/7/2016 4:09 PM, Christopher Tyler wrote: > The problem isn't getting the info that I need or even storing it in a > variable. If I write the script and do one interface per line, this becomes > trivial as each line would have it's own statically named variable. I however > want to keep the script as compact as possible. Thus looping through the > interfaces rather than hard coding each interface. > > If I use a static variable name like the script you referenced below, as the > loop goes through each interface, the variable gets rewritten in each > instance ending with only the value of the last interface, which is useless > for the other interfaces. Unless there is a way to dynamically create and > recall the name of the variable, then this is a non-starter and I'll have to > completely rethink my approach. I'm just not sure that the scripting language > is powerful enough to handle the task as hand as envisioned. > > If I could do something like an array "$interface[$count]", or even just some > way of appending a variable like "$interface.$count" but that doesn't work. > So unless someone has a solution, I'm stuck. > -- Scott Reed Wireless Networking Network Design, Installation and Administration Mikrotik Advanced Certified _______________________________________________ Mikrotik mailing list Mikrotik@mail.butchevans.com http://mail.butchevans.com/mailman/listinfo/mikrotik Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS _______________________________________________ Mikrotik mailing list Mikrotik@mail.butchevans.com http://mail.butchevans.com/mailman/listinfo/mikrotik Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS