Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 23620

Scripting • Re: What does op type (>[ ... ]) do?

$
0
0
There is a detailed explanation written by others on the forum.

Aside from that when you notice a problem, it should be minimized to remove as many parameters as possible:

example code

{:local y ; # used later:local z 10:local j 11:local x (>[:set y 44 ; :local overwritek 7 ; :local overwritew 19]):local k 12:local w 13:put "y: $y":put "z: $z":put "j: $j":put "k: $k":put "w: $w"$x:put "y: $y":put "z: $z":put "j: $j":put "k: $k":put "w: $w"}y: z: 10j: 11k: 12w: 13y: 44z: 10j: 11k: 7w: 19
The call of the function overwrite the value of the next declared variable because >[] is used.
Is one undocumented feature because is not done and not completely working.
Declaring first (as must be done) the variable, solve the "problem"...


Writing correctly often avoids unexpected situations....

example code

{:local sat:local prefix:local suffix:local split (>[     :set sat [:find key=":" in=$1]    :set prefix [:pick $1 0 $sat]    :set suffix [:pick $1 ($sat + 1) [:len $1]]            ]):local abc 10:put "abc: $abc"$split "ghi:jkl":put "abc: $abc":put "prefix: $prefix":put "suffix: $suffix"}abc: 10abc: 10prefix: ghisuffix: jkl

Statistics: Posted by rextended — Sat Mar 29, 2025 12:40 pm



Viewing all articles
Browse latest Browse all 23620

Trending Articles