Computer Science Canada

weird problem with if statement

Author:  person [ Wed Feb 02, 2005 4:52 pm ]
Post subject:  weird problem with if statement

y doesnt this work?
its supposed to check if a dot's colour is 1 or 44, and if its not 1 or 44 then draw a circle there

code:

if whatdotcolor (40, 40) not= (44 and 1) then
    drawfilloval (40, 40, 35, 35, 1)
end if

Author:  cycro1234 [ Wed Feb 02, 2005 4:59 pm ]
Post subject: 

why do u have

if whatdotcolor (40, 40) not= (44 and 1) then


the and there?? its:

if whatdotcolor (40, 40) not= *insert colour here*

Author:  person [ Wed Feb 02, 2005 5:02 pm ]
Post subject: 

ummm.....maybe 44 and 1 r colours?

Author:  Bacchus [ Wed Feb 02, 2005 5:02 pm ]
Post subject: 

thats not how u use and. you need to do
code:
if whatdotcolor(x,y)not=color1 & whatdotcolor(x,y) not=color2 then

Author:  md [ Wed Feb 02, 2005 5:03 pm ]
Post subject: 

I'm not sure what cryo

Author:  person [ Wed Feb 02, 2005 5:04 pm ]
Post subject: 

so wat does turing think im trying to say when i use my previous code?

Author:  Bacchus [ Wed Feb 02, 2005 5:05 pm ]
Post subject: 

no idea im not turing

Author:  cycro1234 [ Wed Feb 02, 2005 5:06 pm ]
Post subject: 

I don't think Turing understands that.

Author:  person [ Wed Feb 02, 2005 5:08 pm ]
Post subject: 

if it doesnt understand it, y does it still run?

Author:  cycro1234 [ Wed Feb 02, 2005 5:09 pm ]
Post subject: 

Hey, I'm just a noob Sad

Author:  person [ Wed Feb 02, 2005 9:08 pm ]
Post subject: 

code:

if whatdotcolour (x,y) = (colour1 and colour2) then
       % stuff
end if


wat does this mean if it doesnt mean...

code:

if whatdotcolour (x,y) = colour1 and whatdotcolour (x,y) = colour2 then
       % stuff
end if


i know its not an error because turing actually runs it

Author:  cycro1234 [ Wed Feb 02, 2005 9:30 pm ]
Post subject: 

Well if it doesn't work, don't use it Smile

Author:  person [ Wed Feb 02, 2005 9:40 pm ]
Post subject: 

y doesnt it work?

Author:  cycro1234 [ Wed Feb 02, 2005 9:42 pm ]
Post subject: 

I dunno, ask some1 whose not n00bish.

Author:  TheZsterBunny [ Wed Feb 02, 2005 11:57 pm ]
Post subject: 

Turing is not like most other languages.

to compare a value to other values, you must use different statements.

code:

if x=1 or x=5 then
%stuff
end if


also, perhaps you may wish to rephrase that statement.

code:

if whatdotcolor(x,y)_ ~= color1 and whatdotcolor(x,y) ~= color2 then
% stuff
end if


What you have doesn't make sense to turing. you are comparing the value of (whatdotcolor(40,40)) to (44 and 1). NOT them individually, but together. -- Bad!

another way (if you want)--
code:

if whatdotcolor(40,40) = 44 or whatdotcolor(40,40) = 1 then
%its bad!
else
%its good!
end if



but that'll probably get you yelled at.

-Z

Author:  Cervantes [ Thu Feb 03, 2005 7:51 am ]
Post subject: 

person wrote:
so wat does turing think im trying to say when i use my previous code?


Try the folllowing code:
Turing:

put 44 and 1


Wink

Author:  person [ Thu Feb 03, 2005 1:06 pm ]
Post subject: 

y does it output 0?

Author:  cycro1234 [ Thu Feb 03, 2005 1:53 pm ]
Post subject: 

Doing :

code:

put 44 and 100


Give me 36. Why is that?

Author:  TheZsterBunny [ Thu Feb 03, 2005 7:01 pm ]
Post subject: 

natural numbers.

[big storybook lettering]I[/bsl]n turing, the and operator can compare two numbers bitwisely.

The result is the natural number that is the bit-wise and of the operands.

i.e.
[syntax=turing]
var number : nat := 16#ABCD %49381
var mask : nat := 16#FF % 255
put number and mask % Outputs 205 (CD16)
[/syntax]

...yeah...

-Z

Author:  rizzix [ Thu Feb 03, 2005 7:04 pm ]
Post subject: 

cycro1234 wrote:
I dunno, ask some1 whose not n00bish.


hey watch it.. shut up and post something productive. ur useless posts need to stop.. or we'll have to reduce ur ranke to lamer. and u dont want that happening.

Author:  Viper [ Sat Feb 05, 2005 1:21 pm ]
Post subject: 

y dont u jus

if whatdotcolor (x,y)not=44 or whatdotcolor(x,y)not=1 then
drawfilloval (x,y,r1,r2,colour)
end if

Author:  Bacchus [ Sat Feb 05, 2005 3:14 pm ]
Post subject: 

i think he wanted and not or Razz and weve already told him that, he just wanted to kno y his didnt work also

Author:  Viper [ Mon Feb 07, 2005 2:28 pm ]
Post subject: 

yeah sry i didnt realize there were 2 pages lol Embarassed Embarassed

Author:  person [ Mon Feb 07, 2005 5:19 pm ]
Post subject: 

how could u have missed the 1st page??
and also if u only read the 2nd page....u well...wouldnt know wat the thread was talking about


: