Description:
In this challenge you are asked to create an alias that will take the inputted switches (such as those you would put in a native mIRC command) and return the corresponding switch or its data if the .data property is supplied
Syntax:
$switch(<switches>,<N/switch char>)[.data]
If
N is a number, it should return the Nth switch. If
N is 0, it should return the total switches.
If
char is supplied, it should return the same char if the switch exists.
.data can be supplied at any point and it should return the data for that switch i.e. for the Nth switch, or data for switch <char>.
Specifications:
- A switch is a case-sensitive character a-z.
- Each switch can have its own numerical data (may be negative and have decimals) following it;
$switch(a4b7,b) = b
The data may also be enclosed in quotes (" ");
$switch(a"switch a quote data"b"switch b quote data",b).data = switch b quote data
Validation
You can assume:
- Checking for non-existent switches will be tested, in which case your alias should return $null
- $2 will always be a letter (a-z or A-Z) or a whole number >= 0
- $switch(<switches>,0).data will not be tested
- If .data is supplied but the switch doesn't have any "data", your alias should return $null
- Quotes with data can have any character in it but "
- There will always be data within the quotes
- No switch will be repeated twice
Example:
$switch(abc,0) = 3
$switch(abc,1) = a
$switch(abc,c) = c
$switch(abc,b).data = $null
$switch(abc,4) = $null
$switch(ab9z8.98,z).data = 8.98
$switch(mBv,z) = $null
$switch(mB"v"v"mB",B).data = v
$switch(mB"v"v"mB",v).data = mB
$switch($null,0) = 0
$switch($null,1) = $null
$switch(abc,0).data = NOT TESTED
$switch(a""b,a).data = NOT TESTED
$switch(aba,a) = NOT TESTED
Rules:
- Tested in a clean, offline mIRC 6.35
- Will be loaded in ALIASES section (i.e "switch {" -- NOT "alias switch {"
- MUST HAVE closing bracket -- if not supplied it WILL be added on
- No COMs, DLLs, or sockets
- Alias must give correct results after consecutive runs