BUG - :tostr $Variable does not work in 6.6

In versions 6.5 and 6.6 using the Log parser script as posted on the wiki http://wiki.mikrotik.com/wiki/Log_Parser_-_Event_Trigger_Script no longer works.

I have isolated the script down to the problem that converting a variable to a string results in no error, however creates a blank value in the variable. After a downgrade to 5.26, it again works properly.

For example:

:local LogVar
:set LogVar ".id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info"
:tostr $LogVar
:put "This is a test on the first line"
:put $LogVar
:put "This is the last line"

Output results:

>This is a test on the first line
>
>This is a test on the last line

Anyone else seeing this problem, or know of a fix/workaround?

Hi
Did you come up with a solution? I am also facing the same issue :tostr creates an empty string.

Poste YOUR CODE to make possible to check for errors.

In the previous post the error are: incorrect and incomplete syntax.

The script do:
:local LogVar
declare one undefined empty variable called LogVar of type “nothing”

:set LogVar “.id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info”
this do nothing, missing $ before LogVar for call already existing variable

:tostr $LogVar
this line do nothing. this command return one value, do not write that value inside $logVar or convert $LogVar.

:put “This is a test on the first line”
ok

:put $LogVar
this write logvar contents, if wrong “set” syntax is used, is empty.

:put “This is the last line”
ok

and that are other syntax errors:

:local LogVar
miss value=“”;

:set LogVar “.id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info”
set do not create variables, but assing a value to one already existent variable, $ must be used, and miss value= and ;

:tostr $LogVar
and this? where is put the result? $LogValue remain untouched. must be writed: “:set $LogVar value=[:tostr $LogVar];”

:put “This is a test on the first line”
missing message= and ;

:put $LogVar
missing message= and ;

:put “This is the last line”
missing message= and ;

IN THE TERMINAL THE SCRIPT CAN NOT BE TESTED IF YOU OMIT { AT THE START AND } AT THE END.



fixing all the errors, but not the concept, the result are:

:local LogVar value="";
:set $LogVar value=".id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info";
:set $LogVar value=[:tostr $LogVar];
:put message="This is a test on the first line";
:put message=$LogVar;
:put message="This is the last line";

and the results (on terminal):
[admin@MATRIX] > {:local LogVar value=“”;
{… :set $LogVar value=“.id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info”;
{… :set $LogVar value=[:tostr $LogVar];
{… :put message=“This is a test on the first line”;
{… :put message=$LogVar;
{… :put message=“This is the last line”;}
This is a test on the first line
.id=*152fd;message=00:0C:42:7F:A2:94@RFSouthG: connected;time=nov/11 22:25:22;topics=wireless;info
This is the last line
[admin@MATRIX] >�

Regarding the scripts from this wiki entry → http://wiki.mikrotik.com/wiki/Log_Parser_-_Event_Trigger_Script

I changed the following lines:


Log Parser Script
#####################

FROM:

# Get each log entry's properties
   :foreach item in=[:toarray $rule] do={
      :set findindex [:find [:tostr $item] "="]
      :set property [:tostr [:pick [:tostr $item] 0 $findindex]]
      :set value [:tostr [:pick [:tostr $item] ($findindex + 1) [:len [:tostr $item]]]]
      :if ([:tostr $property] = "time") do={ :set logEntryTime $value }
      :if ([:tostr $property] = "topics") do={ :set logEntryTopics $value }
      :if ([:tostr $property] = "message") do={ :set logEntryMessage $value }
# end foreach item

TO:

# Get each log entry's properties
   :local items {$rule}
   :foreach item in=[$items] do={
      :set logEntryTime ($item->"time")
      :set logEntryTopics ($item->"topics")
      :set logEntryMessage ($item->"message")
   }
# end foreach item

FROM:

#   Set logParseVar, then run parser script
      :set logParseVar ($logEntryTime . "," . $logEntryTopics . "," . $logEntryMessage)

TO:

#   Set logParseVar, then run parser script
      :set logParseVar {$logEntryTime ; $logEntryTopics; $logEntryMessage}

Parser Action Script
#####################

FROM:

:local logTime [:pick [:toarray $logParseVar] 0]
:local logTopics [:pick [:toarray $logParseVar] 1]
:local logMessage [:pick [:toarray $logParseVar] 2]

TO:

:local logTime ($logParseVar->0)
:local logTopics [:tostr ($logParseVar->1)]
:local logMessage [:tostr ($logParseVar->2)]

I hope i covered all steps I did during testing. My own script does not reflect the original in detail anymore, cause I modified it for my needs.