wifinigel.MikrotikScripting/scripts/v7/ch4-02-ip-prefix-slicer.rsc

14 lines
475 B
Text
Raw Normal View History

2023-01-19 21:27:15 +00:00
# ch4-02-ip-prefix-slicer.rsc
# Create a function to slice up an IP prefix
:global IpPrefixSlicerFunc do={
2023-01-24 20:28:40 +00:00
:local InterfaceIp ([/ip/address get $1]->"address");
2023-01-19 21:27:15 +00:00
:local SlashPosition [:find $InterfaceIp "/"];
:local IpAddress [:pick $InterfaceIp 0 $SlashPosition];
:return [:toip $IpAddress]
}
# Run the function for ID *1 and verify data type of result
:local IpAddress [$IpPrefixSlicerFunc *1];
:put ("Result: $IpAddress");
:put ("Data type: " . [:typeof $IpAddress]);