>>
var aMyLinker:Array = [null, undefined, "", "somnething"];
for (var i:Number = 0; i < 4; i++)
{
        trace("aMyLinker" + i + " = " + aMyLinker[i]);
        if ((aMyLinker[i] != "") || (aMyLinker[i] != undefined) || 
(aMyLinker[i] != null))
        {
                trace(" i exectue!");
        }
}

Now as my understanding is this should not trace "I execute" UNLESS one 
of the array values is equal to something BESIDES null, undefined or "".
So the results should be:

aMyLinker0 = null
aMyLinker1 = undefined
aMyLinker2 =
aMyLinker3 = somnething
  i exectue!
<<

now here is what happens:

lets do it with boolean functions: 

a(x) := (x != "");
b(x) := (x != undefined);
c(x) := a(x) || b(x); //a OR b must be true for c to be true

- means that the expression does not get evaluated if we ask for c(x)
(lazy evaluation -> from left to right until something is true)

x               a(x)            b(x)            c(x)                   
--------------------------------------------------------
null            true            -               true    -> I execute
undefined       true            -               true  -> I execute
""              false           true            true    -> I execute
"something"     true            -               true    -> I execute

now lets add another function

a(x) := (x != "");
b(x) := (x != undefined);
d(x) := a(x) && b(x);  //a AND b must be true for d to be true

and call it:

x               a(x)            b(x)            d(x)                   
--------------------------------------------------------
null            true            false*  false
undefined       true            false           false
""              false           -               false
"something"     true            true            true    -> I execute

*: Not quite sure about this one, I think its null==undefined and null !==
undefined, but may be wrong here.



Does that make things clearer to you?




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of dnk
Sent: Tuesday, August 15, 2006 10:24 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] [:::] appending html to avar for displaynot
workingand code not runnign as expected.

André Goliath wrote:
> Yes, but you need to connect them with AND and not with OR, try this:
> 
> (this is your current code)
> 
> // 
> //
> var myLinker1 = undefined;
> trace("myLinker1 = "+myLinker1);
> if ((myLinker1 != "") || (myLinker1 != undefined) || (myLinker1 != null))
{
>       trace(" i exectue!");  //traces
> }
> var myLinker1 = "";
> trace("myLinker1 = "+myLinker1);
> if ((myLinker1 != "") || (myLinker1 != undefined) || (myLinker1 != null))
{
>       trace(" i exectue!"); //traces
> }
> var myLinker1 = null;
> trace("myLinker1 = "+myLinker1);
> if ((myLinker1 != "") || (myLinker1 != undefined) || (myLinker1 != null))
{
>       trace(" i exectue!"); //traces
> }
> 
> // my Code
> 
> var myLinker1 = "";
> trace("myLinker1 = "+myLinker1);
> if ((myLinker1 != "") && (myLinker1 != undefined) && (myLinker1 != null))
{
>       trace(" i exectue!"); //does NOT trace
> }
> 
>


Just to be clear I want to code to execute if the var is undefined or 
null or an empty string.



now here is my exact test code (modified to loop though):

var aMyLinker:Array = [null, undefined, "", "somnething"];
for (var i:Number = 0; i < 4; i++)
{
        trace("aMyLinker" + i + " = " + aMyLinker[i]);
        if ((aMyLinker[i] != "") || (aMyLinker[i] != undefined) || 
(aMyLinker[i] != null))
        {
                trace(" i exectue!");
        }
}

Now as my understanding is this should not trace "I execute" UNLESS one 
of the array values is equal to something BESIDES null, undefined or "".
So the results should be:

aMyLinker0 = null
aMyLinker1 = undefined
aMyLinker2 =
aMyLinker3 = somnething
  i exectue!

But i am getting:

aMyLinker0 = null
  i exectue!
aMyLinker1 = undefined
  i exectue!
aMyLinker2 =
  i exectue!
aMyLinker3 = somnething
  i exectue!

Am I misunderstanding something so basic here?

!= checks for inequality correct?
|| defines OR correct?

so any comparisons separated by the || should check if any of the 
comparisons are true. As in any one of them correct?

I have to be missing something here......


Thanks to everyone.

d

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to