mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 109
T
Vogon poet
OP Offline
Vogon poet
T
Joined: Dec 2002
Posts: 109
/help if-then-else states:

***
You can use the ! prefix in front of variables and identifiers in an if-then-else statement to negate a value. The following statements are equivalent.

if (%x == $null) echo x has no value
if (!%x) echo x has no value
***

Now, at least the way I read this, it is saying that A implies B and B implies A, but that is not the case.

* While it is true, that the two statements match for %x == $null
* it is not true that (!%x) will always produce the same result as (%x == $null)

What about when %x == 0??

"Equivalent", in my dictionary, means that the statements imply one another, when in fact the first implies the second but not the other way around.

Anyone else?


<Ingo> I can't uninstall it, there seems to be some kind of "Uninstall Shield"
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Its funny you bring that up. I was making a dialog for an SMS suggestion that was posted on here, and the number needs to be in XXX-XXX-XXXX format, so i used a while loop to "read" each number and place it in the proper syntax ex:

Code:
+----------------+ Number:
|1234567890      | 123-456-7890
+----------------+


Well, that worked find. I used:
Code:
var %a = 1
while ($mid($did($did), %a, 1)) {

And went through all the individual letters. Now, I was thinking "while the mid character is not null", so i figure im in the clear. It worked perfectly, but one problem. If i put a 0 anywhere in the number, that 0 and the following numbers were truncated...
Code:
+----------------+ Number:
|1034567892      | 1XX-XXX-XXXX
+----------------+

So now im thinking "wtf" its not working, its not null, whats going on here. Well, after echoing and debugging i found out that mid of the number (being 0) returns false in the while killing the loop. So now, i had to change it to
Code:
var %a = 1
while ($mid($did(dd), %a, 1) != $null) {

and worked fine ever since laugh Kida wierd of it worked out. You think "gonna return true cause its not null. It really should be a null-or-not condition and use variables that hold $true and $false not 1 and 0 for a condition. Similar to a bool type. >:D


-KingTomato
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Quote:
"Equivalent", in my dictionary, means that the statements imply one another, when in fact the first implies the second but not the other way around.


Yes that would be the general (mathematical) definition of equivilence, A = B and B = A. So I'd agree it's a typo. Plus the "echo x has no value" is also misleading since it may very well have a value of $false or 0.


Link Copied to Clipboard