How do you use this script?
Obviously the response is a year late or so but, to answer your question, all you do is copy and paste the ROS code above into whatever script your working on and as indicated in the usage statement above, you can call on it like this from inside your script:
:local ipAddress "10.1.1.20";
:put [$returnOctet $ipAddress 0];
It would return the first octet of "10" and print it to the terminal window. Also as noted above, the second argument 0-3 returns what octet you're looking for. So in the case above, if you put the number 0 through 3, it would return "10", "1", "1", or "20" respectively. It is very helpful in situations where you need to manipulate a specific octet of a variable that contains an IP address.
Or you can directly input the variable and it would output the same thing like this:
:put [$returnOctet 10.1.1.20 0]
Once you've ran the script one time, since it's a global variable, you could then call it directly from the terminal the same way or use it in any other script for that matter as long as you declare ":global returnOctet;" to initialize the variable before you use it as long as you haven't unset the variable by calling ":set returnOctet;" or rebooted your router since you ran the script. Global variables aren't kept after a reboot.
To actually run a script there are several ways that I know of (probably more than this), by opening a terminal and typing "/system script run nameOfScript" or in Winbox go to System > Scripts > Select the script and hit Run Script but you won't see any output that way.