IonicWind Software

IWBasic => General Questions => Topic started by: Ficko on March 01, 2009, 11:21:56 AM

Title: A = B = C ??
Post by: Ficko on March 01, 2009, 11:21:56 AM
I was studying the source of "BitmapToRegion" when I run into this line:

"#<RGNDATA>pData.rdh.nCount = #<RGNDATA>pData.rdh.nRgnSize = 0"  :o

I had a guess that it means "nCount = 0" and "nRgnSize = 0" but after testing it I got very dizzy. :-\

The test01:

DEF A,B:INT
OPENCONSOLE
A = 5
B = 6
A = B = 0
PRINT A
PRINT B
DO:UNTIL INKEY$ <> ""

gives :
0
6
:o

The test02:

DEF A,B,C:INT
OPENCONSOLE
A = 5
B = 6
C = 7
A = B = C
PRINT A
PRINT B
PRINT C
DO:UNTIL INKEY$ <> ""

gives:
0
6
7
:o

What this algo supposed to ???
Just makes no sense!?
Title: Re: A = B = C ??
Post by: Ionic Wind Support Team on March 01, 2009, 11:38:49 AM
It's the assignment of a boolean operation.

Thing of it like this:

a = (b = c)

if b equals c then a = 1
if b not equal c then a = 0

In C/C++ it would be:

a = (b == c)

Emergence allows the non parenthesis form because of order of operators rules.  And assignments are not continued between variable pairs.

It may have made more sense to you if you would have encountered

a = b <> c

Depends on what languages you've used in the past.  I know for instance that PureBASIC doesn't support boolean operations like this.

Paul.
Title: Re: A = B = C ??
Post by: Ficko on March 01, 2009, 11:56:38 AM
Thanks Paul,

I was busy proramming in C# in the last couple of weeks and that language made me very rigid. :(
I just couldn't switch back to EB that easily. ;)

Too much freedom! ;D

Without "==" or "bool" I didn't even consider a boolean expression.