if(usr.Card_Recieve == 0)
else
Problem description:
Whats wrong with this ?
it keeps on saying empty 'else' clause
error: invalid expression ahh!
ID:145074
![]() Jun 20 2006, 8:24 am
|
|
Code:
if(usr.Card_Recieve == 0) Problem description: Whats wrong with this ? it keeps on saying empty 'else' clause error: invalid expression ahh! |
![]() Jun 20 2006, 8:36 am
|
|
You have else tabbed twice. And "if", "else" is doing nuthing.
|
Well; just two things to make this code work better.
if(!usr.Card_Recieve) Using the ! operator infront of something, means that it can either be "FALSE",0, or null. It's better to use this, because it covers more grounds. (And to me it looks alot nicer.) |
trying show the whole code and if it sa proc no usr use src and u dont even need that in if use if(!name) ! means == 0 and if(name) means 1
|
Translation:
Trying show the whole code block. If it is a (mob/)proc, (you do not need to use) usr (but instead use) use src and "you don't even need that in if you use if(!name) [which is ==0] or if(name) [which is ==1]" The whole thing in the quotes is FALSE actually. In certain cases you do need a prefixed variable (...by that I mean like var/mob/M and such)... if(!M.var) will still work. AND (!var) does NOT mean ==0, it means ==FALSE, while (var) means ==TRUE in boolean terms... Click here for boolean information As well as this: if in any atomic proc you use that you know for certain that it is a src., you don't even need to add that part in as src. is the default <.< - GhostAnime |
Gebsbo wrote:
Code: if(usr.Card_Recieve == 0) Not you, Gebsbo wrote it. It is ultra important to spell code correctly, it has grammar, just like english or french, If after 100,000 lines of code you start spelling usr.Card_Recieve correctly there will be errors galore. Otherwise he will be obliged to spell it wrong throughout the whole of the project. |
GhostAnime wrote:
AND (!var) does NOT mean ==0, it means ==FALSE, while (var) means ==TRUE in boolean terms... Click here for boolean information Actually, TRUE is defined as 1, and FALSE, 0. See, in BYOND 0, null, and "" are different values. While the statement if(my_var == 0) only checks if my_var is equal to 0, if(!my_var) is equivalent to if(my_var == null || my_var == 0 || my_var == ""). Similarly, if(my_var) is equivalent to if(my_var != null && my_var != 0 && my_var != ""). As well as this: if in any atomic proc you use that you know for certain that it is a src., you don't even need to add that part in as src. is the default <.< It's true enough the typing out of "src." is sometimes optional, but I don't think its typing out is something to be corrected. Personally, I use the optional src (bwicki link) because I find that the pros of using it (clarity, in my opinion) outweight the one and only con (that of having to type out the four extra characters). |
Sorry, I was not thinking clearly when I posted that, too much overtime does that to you >_< though for the ==1/0 thing, it was the way he stated it <.< To me, it sounded like he said only if(var) means if(var==1) and not any other optional TRUE values .-.
- GhostAnime |