ID:120930
 
Not a bug
BYOND Version:493
Operating System:Windows Vista Home Premium 64-bit
Web Browser:Internet Explorer 9.0
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND Developer forums.
Descriptive Problem Summary:The !(not) operator isn't working under certain circumstances.

Numbered Steps to Reproduce Problem:Use the ! operator instead of the if else statement shown in the code snippet below

Code Snippet (if applicable) to Reproduce Problem:
The code workaround
if(copytext(Number,1+Current_Number,2+Current_Number) in list("0","1","2","3","4","5","6","7","8","9"))
else
return 0


the not working code
if(!copytext(Number,1+Current_Number,2+Current_Number) in list("0","1","2","3","4","5","6","7","8","9"))
return 0


Expected Results:The not operator to make it so if the copytext function copies a value not shown in the list for it to return 0.

Also if I placed it wrong here than maybe you can tell me where it should be, but I tried before and after every word/function & before & after the if inside and outside the () & still nothing.

Actual Results:It always fails to call it whether its true or not if you add the ! & remove the else, with else in there, it always calls the else statement of the code if one exists.

Does the problem occur:
Every time? Or how often?Every Time
In other games?All Projects
In other user accounts?All user accounts.
On other computers?All computers, one of them is windows 7 but they all run the same version of BYOND, I used statements like this with similar commands, maybe even identical in the past, and it has worked, but for some reason, either because the command used(copytext) or something else is preventing it from working here.

When does the problem NOT occur?Always

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Not sure, untested so far.

Workarounds:Use an if, else statement instead.

If this is tested using similar code to this & found to be working I can send the code to an e-mail address so the problem can be found.

The in operator has a lower precedence than the ! operator. This has been known about since forever and has been the subject of numerous posts in the developer forums, where you should have tried to resolve this first.
So is there a way to actually fix it without using the workaround i did, such as not using in & using something else or a different operator that's not !

regardless I believe it should work regardless even if you used it right before in almost as if it was a !in(not in) operator of some sort...I tried putting the ! operator everywhere & since it takes priority over ! apparentally then I assume it wouldn't work...
Use parentheses: if(!(a in b)).

The current behavior won't be "fixed" because nothing is broken. Changing the behavior would actually change the way existing games behave.