Community discussions

MikroTik App
 
Regulator
just joined
Topic Author
Posts: 1
Joined: Wed Jan 24, 2018 1:12 pm

Find command returns unclear results

Wed Jan 24, 2018 1:27 pm

Hello everybody,

I have a question about the inconsistent functioning of the "find" command.
I can not understand why I get the following results if I use the <start> parameter and if that's what I want.
The details can be found in my next code sample.
{
# Testsequence
# PosIdx	PosNr	Char	Remark
# 0		1	\r	CR
# 1		2	\n	LF
# 2		3	\r	CR
# 3		4	\n	LF
# 4		5	#
# 5		6	\r	CR
# 6		7	\n	LF

:local content "\r\n\r\n#\r\n";
:put "Result - Find CR - without start index:\t $[:find $content "\r"]\t - expected result:\t0"
:put "Result - Find CR - start index (-1):\t $[:find $content "\r" -1]\t - expected result:\tShould be undefined, because the access seems to lead to an undefined memory position "
:put "Result - Find CR - start index (0):\t $[:find $content "\r" 0]\t - expected result:\t0"
:put "Result - Find CR - start index (1):\t $[:find $content "\r" 1]\t - expected result:\t2"
:put "Result - Find CR - start index (2):\t $[:find $content "\r" 2]\t - expected result:\t2"
:put "Result - Find CR - start index (3):\t $[:find $content "\r" 3]\t - expected result:\t5"
:put "Result - Find CR - start index (4):\t $[:find $content "\r" 4]\t - expected result:\t5"
:put "Result - Find CR - start index (5):\t $[:find $content "\r" 5]\t - expected result:\t5"
:put "Result - Find CR - start index (6):\t $[:find $content "\r" 6]\t - expected result:\tnot found"
:put "Result - Find CR - start index (7):\t $[:find $content "\r" 7]\t - expected result:\tnot found"
}

Thank you for the clarification in advance.

Who is online

Users browsing this forum: No registered users and 34 guests