mIRC Home    About    Download    Register    News    Help

Print Thread
expanded relational comparison for if/then/else #61319 21/11/03 11:43 AM
Joined: Jan 2003
Posts: 154
B
BoredNL Offline OP
Vogon poet
OP Offline
Vogon poet
B
Joined: Jan 2003
Posts: 154
instead of:
if (($1 < $2) && ($2 > $3) && ($3 <= $4)) { whatever }
have this:
if ($1 < $2 > $3 <= $4) { whatever }

this would be legal as well:
if (($1 < $2 > $3 <= $4) || ($1 > $4)) { whatever }
the whole string could be assigned a value as well. If it's true, it would equal 1, if it was false, it would equal 0. This would allow for even more complexity.
For Example:
if (($1 < $2 > $3 <= $4) >= ($1 > $4)) { whatever }
this would run "whatever" only if the first part is true and the second is either true or false, and also when they are both false.

of course these things would only apply to numbers. The following if/then/else equation would not be valid and would cause an '/if error' if $blah returns "hello":
if (($1 < $2 > $3 <= $blah) || ($1 > $4)) { whatever }

however, the following equation would be valid:
if ((($1 < $2 > $3) && $blah) || ($1 > $4)) { whatever }
if $blah returns $null or 0, then the first part of this if/then/else equation would be false, but if it returns "hello", then it will be true as long as $1 < $2 > $3.

smile


- Wherever you go there you are.[color:lightgreen]
Re: expanded relational comparison for if/then/else #61320 21/11/03 07:03 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
This isn't math, there is no order of operations. You're first example would evaluate as

if ((($1 < $2) > $3) <= $4) { whatever }

What are you going to do, explicitly state that >= has more presidance over < which in turn has less presidence than != ? it's just not possible. Find me one structured language that uses this. Personally, i think its a matter of laziness, and not being able to use a couple parenthesis.


-KingTomato
Re: expanded relational comparison for if/then/else #61321 21/11/03 09:43 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Quote:
Find me one structured language that uses this

PHP, Python, and Delphi to start with. And that's the only 3 I happened to check (and have tables at hand). The comparisons themselves don't need precedence over each other, they simply chain together to form larger comparisons or are evaluated from left to right. It would be nice if this was possible, but because mIRC is an untyped language (and an IRC client's scripting language) it doesn't have expressions to the extent that most languages do, so I won't be holding my breath for this one.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: expanded relational comparison for if/then/else #61322 27/11/03 07:33 AM
Joined: Nov 2003
Posts: 35
R
Riamus Offline
Ameglian cow
Offline
Ameglian cow
R
Joined: Nov 2003
Posts: 35
I think that considering the few times you want to tie everything together in such a manner ... usually you are not tying every $_ together at once ... that leaving things the way they are is much better. Why bother coding something like that if it's rarely needed. Perhaps you have a use for it that you are thinking of, but I see little need for it. Especially since it's not that hard to type a few extra characters.

Re: expanded relational comparison for if/then/else #61323 27/11/03 07:49 PM
Joined: Apr 2003
Posts: 85
K
katsklaw Offline
Babel fish
Offline
Babel fish
K
Joined: Apr 2003
Posts: 85
Firstly, there is no 'then' in mIRC if/else statements.

Secondly, can you imagine how many thousands of script this would break for just a few keystrokes? Personally I think
the current method make perfect sence and shouldn't be changed.


--

katsklaw
Rather experienced Admin
Rather experienced mIRC Scripter
Amateur C Coder
Re: expanded relational comparison for if/then/else #61324 27/11/03 08:46 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Riamus:
It would mean less evaluation of variables and identifiers for one thing, meaning faster condition processing when the extended conditions were used instead of excess &&'ing. Personally I don't have a problem with the speed of mIRC script but there are plenty of people who would kill for any performance gain in the language. Like I said before it's not particularly important that this be added, it would just be *nice* if it was.

katsklaw:
Regardless of whether there's a physical 'then' written in the line, an if statement is commonly referred to as if..then or if/then/else or some other twist on the term.

Why would it break scripts? He's not suggesting that conditions be changed, he's suggesting an extension to the expressions that can be used as conditions.


Spelling mistakes, grammatical errors, and stupid comments are intentional.