mIRC Home    About    Download    Register    News    Help

Print Thread
#271097 28/11/22 10:35 AM
Joined: Jan 2012
Posts: 299
Epic Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2012
Posts: 299
IF-ELSEIF-ELSE  ==  IF-ELIF-ELSE


I propose to add to the syntax as an alternative to the command "elseif" a similar command, but a shorter "elif", which will correspond to the number of characters as in the command "else". That is, this must override the current command and must not break backwards compatibility, but must allow a shorter variant of "elseif" == "elif" to be use.

An example of how it maybe look in code:
Code
if (condition) { commands }
elif (condition) { commands }
elif (condition) { commands }
elif (condition) { commands }
else { commands }

In my opinion, such a consistently built code construction looks more neat than it is now:
Code
if (condition) { commands }
elseif (condition) { commands }
elseif (condition) { commands }
elseif (condition) { commands }
else { commands }

In any case, it will be possible to use 2 command options to choose from, but I would prefer to use a shorter variant of the command.
It will also be convenient for those who are used to coding in Python.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Epic #271099 30/11/22 12:11 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Google shows that /elif is a 'thing' in python, where apparently they limit elseif to having only 1 of them, while elif is not limited. But we've already got /elif capability with /elseif, and the only thing that adding /elif would do is create a duplicate /command so that scripts are easier to read.

I counter-propose that, instead of creating a new /command that duplicates the functionality of /elseif, and would limit those scripts from running in older versions, that your desired effect could be achieved by having mid-denting of the script, so that if 'else' is preceded by an 'elseif', that the 'else' be followed by at least 2 spaces, and that if 'if' is followed by 'else' but not 'elseif' that the 'if' has 3 trailing spaces, and make it 5 spaces if the 'if' is trailed by an 'elseif'.

Code
if   (foo == bar) { commands }
else { commands }

if     (foo == bar) { commands }
elseif (foo > bar) { commands }
elseif (foo < bar) { commands }
elseif ($me == foo) { commands }
else  { commands }


Link Copied to Clipboard