Script doesn't continue after a statement [SOLVED]

Hi,
i’ve this script.
The script works fine!
But…
after :foreach {…} statement it doesn’t execute nothing other!
For example a /log info “…” doesn’t works, or a command, or an IF statement… Nothing works after } of the :foreach statement.
I can’t realize what is blocking!
I tried to add { at begin of the script and } to close at the end but nothing.

This is script:

:global currentBuf [ :toarray [ /log find where (message~"logged" || message~"login") ] ] ;
:global currentLineCount [ :len $currentBuf ] ;
:global currentTime [ :totime [/log get [ :pick $currentBuf ($currentLineCount - 1) ] time ] ];
:global messageTime;
:global interv [ /system scheduler get [find name="Test"] interval ] ;
:global message "";
:global diff ($currentTime - $interv);

:foreach i in=[$currentBuf] do={
  :set messageTime [/log get [ :pick $currentBuf ($currentLineCount - 1) ] time];
  :if ( $messageTime >= $diff ) do={
    :set message [/log get [ :pick $currentBuf ($currentLineCount - 1) ] message];
    /log info "test this"
    }
  :set currentLineCount ($currentLineCount - 1);
}

Thanks all.

Maybe, use :log info " " instead of /log info " "

You confused the actual logging and the log menu itself at this line:

/log info "test this"

Hi msatter thank you,
actually I can also remove the instruction “log…” or doing nothing, but the problem remains.

I found!
Sorry!!!

damn!!!
the line offending is:

.....
  :set messageTime [/log get [ :pick $currentBuf ($currentLineCount - 1) ] time] ;
....

if i comment that it works!
so, the solution is to add ad this line :totime !!!
So, the line, finally, looks like this:

 
 :set messageTime [ :totime [/log get [ :pick $currentBuf ($currentLineCount - 1) ] time] ];

I change in SOLVED!
Thank yoy very much!!!

…3 days i searching an explanation!!!
:///

If you do not need the value utside the script and store it for later user, change from global to local variable:
Semicolon are not needed at the end of the line anymore, only if you have more than one command at same line.
So change to this:

:local currentBuf [ :toarray [ /log find where (message~"logged" || message~"login") ] ]

If you do like to examine logs in a external program , have a look at Splunk. See link in my signature.

Good that you managed to solve it yourself. I tested

/log info "test"

and it worked. I never use that and use :log because you can call it wherever you are in ROS. I :log very often to debug my code and I use it as flags to see which line is buggy and if I get the correct values in the variables.

ok, thank you very much! :slight_smile: