Page 1 of 1

/newif problem

Posted: Sat Apr 03, 2004 10:33 pm
by dok
First, to clear up any doubts about using the lastest version, I'm using MQ2-20040403.zip which was just released today, even though it doesn't have an updated changes.txt, it is tonights release. MQ was compiled with MQData and MQParms both enabled.

Now that thats out of the way....

it seems that all the problems since the string parsing with /newif seems to be with the following examples in their most basic form. Any /newif's I've had problems with, if I surround the condition with Math.Calc, it fixes any problems I've had. The problem does not exist if you use 1 instead of true, and 0 instead of false in the following examples. Using ${Bool[TRUE]}/${Bool[FALSE]} in the non-working part does not change the results.

Here's the test to try possibilities with /newif.

Code: Select all

|doesn't work
/newif TRUE==TRUE {
	/echo 1A - true
} else /echo 1A - false 
|returns true
/newif TRUE==FALSE {
	/echo 1B - true
} else /echo 1B - false 
|returns ***true***  Should be false
/newif FALSE==TRUE {
	/echo 1C - true
} else /echo 1C - false 
|returns ***true***  Should be false
/newif FALSE==FALSE {
	/echo 1D - true
} else /echo 1D - false 
|returns true


|Works
/newif ${Math.Calc[TRUE==TRUE]} {
	/echo 2A - true
} else /echo 2A - false 
|returns true
/newif ${Math.Calc[TRUE==FALSE]} {
	/echo 2B - true
} else /echo 2B - false 
|returns false
/newif ${Math.Calc[FALSE==TRUE]} {
	/echo 2C - true
} else /echo 2C - false 
|returns false
/newif ${Math.Calc[FALSE==FALSE]} {
	/echo 2D - true
} else /echo 2D - false 
|returns true


|Works
/newif ${Math.Calc[TRUE]}==TRUE {
	/echo 3A - true
} else /echo 3A - false 
|returns true
/newif ${Math.Calc[TRUE]}==FALSE {
	/echo 3B - true
} else /echo 3B - false 
|returns false
/newif ${Math.Calc[FALSE]}==TRUE {
	/echo 3C - true
} else /echo 3C - false 
|returns false
/newif ${Math.Calc[FALSE]}==FALSE {
	/echo 3D - true
} else /echo 3D - false 
|returns true


|Works
/newif 1==1 {
	/echo 4A - true
} else /echo 4A - false 
|returns true
/newif 1==0 {
	/echo 4B - true
} else /echo 4B - false 
|returns false
/newif 0==1 {
	/echo 4C - true
} else /echo 4C - false 
|returns false
/newif 0==0 {
	/echo 4D - true
} else /echo 4D - false 
|returns true

Please physicially run it and anaylse the results before commenting on this because its getting a little old seeing the "its been fixed patches ago" reply, when clearly its not working as it should be.
[/code]

Posted: Sun Apr 04, 2004 12:04 am
by wassup
Well, you could get a little creative and use some other features... since /newif is temporary until Lax does more work...

This works the way you want it to:

Code: Select all

Sub Main
  /docommand ${If[${String[TRUE].CompareCS[TRUE]},/echo 1A - false,/echo 1A - true]}
  /docommand ${If[${String[TRUE].CompareCS[FALSE]},/echo 1B - false,/echo 1B - true]}
  /docommand ${If[${String[FALSE].CompareCS[TRUE]},/echo 1C - false,/echo 1C - true]}
  /docommand ${If[${String[FALSE].CompareCS[FALSE]},/echo 1D - false,/echo 1D - true]}
/endmacro

Posted: Sun Apr 04, 2004 12:34 am
by Lax
/newif is the new "if" that uses the mq2data system. Once phase 3 starts, /newif will no longer be called /newif, it will simply be /if. I'm not sure if someone committed something that affects /newif since I left, but /newif does the same thing Math.Calc does on the "Conditions" anyway, so there should be zero difference... unless someone made changes.

I wont know for sure until I get home and get back to work on the project on wednesday ;)

Posted: Sun Apr 04, 2004 1:25 am
by dont_know_at_all
Translation: /newif is functionally equivalent to /if n

Code: Select all

/if n TRUE==TRUE /call test
doesn't really make sense.

Posted: Sun Apr 04, 2004 12:15 pm
by Lax
TRUE gets replaced by 1.00 and FALSE gets replaced by 0.000, so that should be checking if 1.00==1.00 and so on. That gets chopped down to 1 term by Calculate (/newif uses Calculate, /if does not) and should be "1". There's no reason for the output of ${Math.Calc[TRUE==TRUE]} to be any different than

Code: Select all

/newif TRUE==TRUE {
/echo 1
} else {
/echo 0
}
Someone on IRC thought they had the latest but in reality didnt have it COMPILED... so.. make sure everything got compiled correctly if you havent ;)