123abc only need 123 :pick how to

example :

:global rx-var [/interface wireless registration-table get 0 rx-rate ]

result : 123Mbps-20MHz/2S

how to get only “123” from string in Mikrotik scripting.


another thing is,

:global rx-var [/interface wireless registration-table get 0 rx-rate ]

can also be 1.2Mbps-20Mhz/2S

now i need only “1.2”


and last, maybe the easy part i need it to be usable in Simple Queue, so converted to bps.

:local long1 123ABC
:local long2 "1.2Mbps-20Mhz/2S"

:log info "Long1 is $long1"
:log info "Long2 is $long2"

:local short1 [:pick $long1 0 3]
:log info "Short1 value is $short1"

:local short2 [:pick $long2 0 3]
:log info "Short2 value is $short2"



Log Print:
nov/26 03:41:58 script,info Long1 is 123ABC 
nov/26 03:41:58 script,info Long2 is 1.2Mbps-20Mhz/2S 
nov/26 03:41:58 script,info Short1 value is 123 
nov/26 03:41:58 script,info Short2 value is 1.2

Yes i know the " : pick " command. but i cant use it i think .

The 123Mbps-20MHz/2S can sometimes be 1.2Mbps-20MHz/2S

i need to strip of the “Mbps-20MHz/2S” , so only 123 or 1.2

maybe it can be done with regular expressions and binary operator ~ , but there is to little info for me to understand in manual


“~” 	binary operator that matches value against POSIX extended regular expression 	Print all routes which gateway ends with 202
/ip route print where gateway~"^[0-9 \\.]*202\$"

Sure it is easy :wink:


:global RX [/interface wireless registration-table get 0 rx-rate]
:log info [:pick $RX 0 [:find $RX "M"]]

Best Regards

Sure it is easy > :wink:

Thanks ADahi ! , i will have a play with it.

i want to achieve a script that will set a simple queue to the wlan.

simple queue needs to be no higher than 80% of the connection data rate.

it also has to be dynamic, so when data rate is going up, so will the queue.

maybe you want to help some more writing such a script