Community discussions

Member Candidate
Member Candidate
Topic Author
Posts: 159
Joined: Wed Jul 18, 2018 3:39 pm

Parser bug

Fri Sep 14, 2018 1:06 am

While trying to code a small script I found a problem with "=" in associative arrays:
[admin@MikroTik] > :put ({"a"."b"=1;"b"."a"=2;"ab"=3});
Basically, in an array, if the key is not a literal, the equal sign is taken as a comparison operator and it is impossible
to use.

My use case is for arrays that contain information abou ip addresses taken from address lists, code such as
:set ($addresses->"$addr") ({"$pt";"total"=1;"address"="$addr";})
Observe that, as I am only using one variable field, I can use the 0 to store it, as a workaround, but in the general case it is a big problem.

I wonder if there is alternative syntax, which is probably needed here...
just joined
Posts: 12
Joined: Tue Jun 20, 2017 3:07 pm

Re: Parser bug

Wed Sep 26, 2018 4:08 pm

:put [[:parse "({$("a" ."b")=1;$("b"."a")=2;\"ab\"=3})"]]

:local a "AAA"; :local b "BBB"; :put [[:parse "({\"$a$b\"=1;ab=2})"]]

Who is online

Users browsing this forum: No registered users and 7 guests