Community discussions

MikroTik App
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Array Problem

Mon Feb 03, 2014 10:01 am

This is the output that I would like to see:

pear=Mikrotik
peach=Abe
apple=12345

However, the script below is giving me this output:

0=pear;0=Mikrotik
1=peach;1=Abe
apple=12345

Any ideas why?
{ :local arr {""}; \
:set arr {\
"apple"=12345 ;\
"pear"=[/system identity get name;] ;\
"peach"="Abe" }; \

:put $arr; \
:put [:typeof $arr]; \
:put [:len $arr]; \

:foreach k,v in=$arr do={ \
  :put ("$k=$v") ; \
}; \

:put ($arr->"apple"); \
};
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Re: Array Problem

Mon Feb 03, 2014 9:04 pm

Anyone? What am I doing wrong here?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Array Problem

Mon Feb 03, 2014 9:22 pm

It's a RouteOS bug... see this post. Apparently, it's still not fixed... assuming you have 6.9.
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Re: Array Problem

Mon Feb 03, 2014 9:53 pm

Thank you :)

I am running version 6.7
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7198
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Array Problem

Tue Feb 04, 2014 4:28 pm

Works fine in v6.9

ros code

[admin@MikroTik] > :global rr { "apple"=12345; "pear"=[/system identity get name]; "peach"="abe" }
[admin@MikroTik] > :put $rr 
apple=12345;peach=abe;pear=MikroTik
[admin@MikroTik] > :put ($rr->"apple")
12345
[admin@MikroTik] > :foreach k,v in=$rr do={ :put ("$k=$v") }
apple=12345
peach=abe
pear=MikroTik
[admin@MikroTik] >
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Re: Array Problem

Tue Feb 04, 2014 11:40 pm

Thanks for verifying this :)
I am going to update!

I just updated and it works great!!!