Community discussions

MikroTik App
 
anassar26
just joined
Topic Author
Posts: 21
Joined: Sun Aug 02, 2020 3:20 pm

help get wrong result

Wed Aug 12, 2020 8:58 pm

i use script below but get wrong result when run script
assume data in comment = 10
equation = comment value * 1000
the result must be = 10 * 1000 = 10000
i get result =10 why??
please help me to solve this problem

Script ;
:foreach i in=[/ip hotspot user find ] do={
:local comment [/ip hotspot user get value-name=comment $i ]
:local downquotamb [:tostr [:pick $comment 0 3]]
:local downquota [$downquotamb * 1000]
:put $downquota
}

Result :
[admin@MikroTik] > :foreach i in=[/ip hotspot user find ] do={
{... :local comment [/ip hotspot user get value-name=comment $i ]
{... :local downquotamb [:tostr [:pick $comment 0 3]]
{... :local downquota [$downquotamb * 1000]
{... :put $downquota
{... }
cou

10
 
msatter
Forum Guru
Forum Guru
Posts: 2941
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: help get wrong result

Wed Aug 12, 2020 9:33 pm

:tonum and () instead of [] for arithmetic stuff.
 
anassar26
just joined
Topic Author
Posts: 21
Joined: Sun Aug 02, 2020 3:20 pm

Re: help get wrong result

Wed Aug 12, 2020 10:26 pm

:tonum and () instead of [] for arithmetic stuff.
many thanks my brother
i changed scrip to arithmetic stuff but get same result " 10 "
please help me

Script :

:foreach i in=[/ip hotspot user find ] do={
:local comment [/ip hotspot user get value-name=comment $i ]
:local downq [:tostr [:pick $comment 0 3]]
:local downquotamb (:tonum (:pick $downq ))
:local downquota [$downquotamb * 1000]
:put $downquota
}
 
msatter
Forum Guru
Forum Guru
Posts: 2941
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: help get wrong result

Wed Aug 12, 2020 11:20 pm

:local downquotamb [:tonum [:pick $comment 0 3]]
:local downquota ($downquotamb * 1000)
Something like that. I can't test it on the moment but this what the manual stated.

I did not know that I had an other brother. ;-)
 
anassar26
just joined
Topic Author
Posts: 21
Joined: Sun Aug 02, 2020 3:20 pm

Re: help get wrong result  [SOLVED]

Thu Aug 13, 2020 12:05 am

:local downquotamb [:tonum [:pick $comment 0 3]]
:local downquota ($downquotamb * 1000)
Something like that. I can't test it on the moment but this what the manual stated.

I did not know that I had an other brother. ;-)
Many Thanks ... amazing
Script Working
thank you
 
msatter
Forum Guru
Forum Guru
Posts: 2941
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: help get wrong result

Fri Aug 14, 2020 1:42 pm

Great news. Really good to see that you solved it on your 'own'. ;-)
 
moezaitoun
just joined
Posts: 1
Joined: Wed Aug 19, 2020 8:19 pm

Re: help get wrong result

Wed Aug 19, 2020 8:25 pm

hello

i need scrip can drop the interface when show specific ip address on dst-nat please

its urgent case

thank you

Who is online

Users browsing this forum: malks and 10 guests